Answer to Question #329517 in Java | JSP | JSF for Mark

Question #329517

Write a java program to print all natural numbers from 1 to n - using while loop

1
Expert's answer
2022-04-16T12:57:03-0400




import java.util.Scanner;






class App {


	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		System.out.print("Ente n: ");
		int n = keyBoard.nextInt();
		int i=1;
	    while(i<=n){
	        System.out.println(i);
	        i++;
	    }
		keyBoard.close();


	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS