Write a java program to print all natural numbers from 1 to n - using while loop
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();
}
}
Comments
Leave a comment