1.

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

Answer»

Answer:

The first 10 NATURAL nos are:

1

2

3

4

5

6

7

8

9

10

Explanation:

public class Exercise10 {

   

 public STATIC void MAIN(STRING[] args)

   {      

   int i;

System.out.println ("The first 10 natural numbers are:\n");

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

{      

 System.out.println (i);

}

System.out.println ("\n");

}

}



Discussion

No Comment Found