Create a small program of about 10 to 15 lines which contains at least one if else condition and a for the loop.

Program Code:
public class Prog1
{
public static void main(String[] args)
{
System.out.println("\n The program is showing even number :");
for(int i=2;i<=10;i++)
{
if(i%2==0)
{
System.out.print("\n "+i);
}
}
}
}

Compile:
D:>javac Prog1.java
Run:
D:>java Prog1

Output:
The program is showing even number:
2
4
6
8
10
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: