Write a program to print first 20 even numbers in descending order
Answers
Answered by
5
The no. which is at last in the series of the first 20 even numbers, will be used as the first no. as it is given in the question that we have to print series in descending order. Then the next even number is extracted by subtracted 2 from the original number. Likewise, this series will be printed.
Program :-
class d \\class declaration
{
public static void main (String args[]) \\main() method declaration
{
System.out.println("First 20 even numbers in descending order");
for (int i = 40; i>=2; i-=2)
{
System.out.println(i);
}
}
}
Output :-
First 20 even numbers in descending order
40
38
36
34
32
30
28
26
24
22
20
18
16
14
12
10
8
6
4
2
Glossary :-
Similar questions