-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOddAndEven.java
More file actions
27 lines (26 loc) · 768 Bytes
/
OddAndEven.java
File metadata and controls
27 lines (26 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
Write a Java program to get 10 array elements, from user and put even and odd elements in separate array. Explain • public static void main (String [] args) {}
*/
import java.util.Scanner;
public class OddAndEven{
public static void main(String []args){
int [] array=new int[10];
Scanner s=new Scanner(System.in);
System.out.println("Enter 10 number");
for(int i=0;i<array.length;i++){
array[i]=s.nextInt();
}
System.out.println("Even numbers are;");
for(int i=0;i<array.length;i++){
if(array[i]%2==0){
System.out.println(array[i]);
}
}
System.out.println("odd numbers are;");
for(int i=0;i<array.length;i++){
if(array[i]%2==1){
System.out.println(array[i]);
}
}
}
}