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]);
}
}
}
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]);
}
}
}
No comments:
Post a Comment