Write a program in Java to display the natural numbers from 1 to n.
Answers
Answered by
0
import java.util.Scanner;
public class Main
{
private static Scanner sc;
public static void main(String[] args) {
System.out.println("Hello World");
int number, i;
sc = new Scanner(System.in);
System.out.print(" Please Enter any Number : ");
number = sc.nextInt();
for(i = 1; i <= number; i++)
{
System.out.print(i +"\t");
}
}
}
Similar questions