WAP to print first 15 even numbers.

2 years ago
OOP Java

Compile code:

public class First15EvenNumber
{  
public static void main(String args[])   
{  
int number=100;  
System.out.print("List of even numbers from 1 to "+number+": ");  
for (int i=1; i<=number; i++)   
{  
 

if (i%2==0)   
{  
System.out.print(i + " ");  
}  
}  
}  
}  

 

Output:

 

0
Dipti KC
Jan 8, 2023
More related questions

Questions Bank

View all Questions