public class Sorting {
public static void main(String[] args) {
int a[]={11,23,32,46,51,65,77,89,98};
System.out.println("even numbers");
for(int i=0;i<=8;i++) //array size
{
if(a[i]%2==0)
System.out.println(a[i]);
}
System.out.println();
System.out.println("Odd numbers");
for(int j=0;j<=8;j++)
{
if(a[j]%2==1)
System.out.println(a[j]);
}
}}
OUTPUT:
even numbers
32
46
98
Odd numbers
11
23
51
65
77
89
public static void main(String[] args) {
int a[]={11,23,32,46,51,65,77,89,98};
System.out.println("even numbers");
for(int i=0;i<=8;i++) //array size
{
if(a[i]%2==0)
System.out.println(a[i]);
}
System.out.println();
System.out.println("Odd numbers");
for(int j=0;j<=8;j++)
{
if(a[j]%2==1)
System.out.println(a[j]);
}
}}
OUTPUT:
even numbers
32
46
98
Odd numbers
11
23
51
65
77
89
No comments:
Post a Comment