Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Monday, 26 September 2011

Java program to find even and odd numbers from 20 numbers (by noor diana)

import java.util.*;
class evenodd
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int a[]= new int[20];
System.out.println ("\n\t You must enter 20 numbers");
for (int i=0;i<20;++i)
{
System.out.print ("\n\t Enter the number = ");
a[i]=in.nextInt();
}

System.out.println ("\n\t Even numbers : ");
for (int i=0;i<20;++i)
{
if (a[i]%2==0)
System.out.println ("\t"+a[i]);
}

System.out.println ("\n\t Odd numbers : ");
for (int i=0;i<20;++i)
{
if (a[i]%2!=0)
System.out.println ("\t"+a[i]);
}

}
}