Write a program called ListEvenNumbers wich prints the even numbers from 20 to 30 (including 30). and that prints the below (there is a single spacebetween each number) Printing even numbers between 20 and 30 (including 30). 20 21 22 23 24 25 26 27 28 29 30
Write a
between each number)
Printing even numbers between 20 and 30 (including 30).
20 21 22 23 24 25 26 27 28 29 30
As there is no programming language mentioned, we are doing this program in java to print even numbers between 20 to 30 (including 30).
The following java program will print even numbers between 20 to 30(including 30)
public class ListEvenNumbers {
public static void main(String[] args) {
System.out.println("Printing Even numbers between 20 and 30 (including 30)" );
for(int i=22; i <= 30; i++){
// if the number is divisible by 2 then it is even
if( i % 2 == 0){
System.out.print(i + " ");
}
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images