Java-How to print the first 10 natural numbers

0 0
Read Time:20 Second

Write a program in Java to print the first 10 natural numbers.
Sample output:
The natural numbers are:
1 2 3 4 5 6 7 8 9 10

class Program{
public static void main(String args[]){ 
  System.out.println(" Find the first 10 natural numbers:");
  System.out.println("---------------------------------------");
  System.out.println(" The natural numbers are: ");
  for (int i = 1; i <= 10; i++) {
         System.out.println(i+" ");
    }
  }
}
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Comment

Verified by MonsterInsights