PRINT EVEN NUMBERS OF THE ARRAY 1 TO 10 FROM ARRAY IN JAVA?
INPUT:-
import java.util.Scanner;
public class example{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n[]= new int[10];
int i;
System.out.println("Enter your elements : ");
for(i=0;i<10;i++)
{
n[i]=sc.nextInt();
}
System.out.println("Your even numbers : ");
for(i=0;i<10;i++)
{
if(n[i]%2==0){
System.out.println(n[i]);
}
}
} }
OUTPUT:-
0 Comments