Showing posts with label odd numbers. Show all posts
Showing posts with label odd numbers. Show all posts

Thursday, 20 July 2017

To sort given numbers even and odd

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