Saved Bookmarks
| 1. |
write a program in Java to print first 10 natural numbers using 'for' loop with their sum with correct syntax. |
|
Answer» Answer: 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"); } } |
|