Java program to display even number up to 20

Java Program to display even number up to 20

Java Program to display 20 even number

Java Program to display 20 even number using for loop

Program:-

class simple
{
public static void main(String args[])
{
int num;
for(num=0; num<=20; ) { num = num + 2; System.out.println(num); } } } Output:-

2
4
6
8
10
12
14
16
18
20

Java Program to display 20 even number using while loop

Program:-

class simple
{
public static void main(String args[])
{
int num = 0;
//while loop
while(num<=20) { num = num + 2; // print even number System.out.println(num); } } } Output:-

2
4
6
8
10
12
14
16
18
20


Java Program to display 20 even number using do while loop

Program:-

class group{
public static void main(String args[]){
int num = 0;
// do while loop
do
{
num = num + 2;
// Display even number
System.out.println(num);
}
while(num<20); // Condition } } Output:-

2
4
6
8
10
12
14
16
18
20



Learn Java:-
Java codes

Java Programs:-
List of Java Programs

Leave reply

Add your comments here

Back to Top