Dremendo Tag Line

Print first 20 natural numbers in reverse order using for loop in Java

for Loop - Question 2

In this question, we will see how to print the first 20 natural numbers in reverse order in Java programming using for loop. To know more about for loop click on the for loop lesson.

Q2) Write a program in Java to print the first 20 natural numbers in reverse order using for loop.

Program

public class Q2
{
    public static void main(String args[])
    {
        int i;

        for(i=20; i>=1; i=i-1)
        {
            System.out.println(i);
        }
    }
}

Output

20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1 
video-poster