1.

Write a program in Java to print first 10 natural numbers using 'for' loop with correct syntax.​

Answer»

IMPORT java.util.Scanner ;

class Natural_no

{

void MAIN ()

{

INT n,i;

Scanner kb =newScanner(System.in);

System.out.println ("ENTER the value for n:");

n=kb.nextInt ();

for (i=1;i <=n;i++)

}

System.out.println (i);

}

}

}

Output : Enter the value for n : 10

1

2

3

4

5

6

7

8

9

10



Discussion

No Comment Found