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
Post A Comment:
0 comments: