Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
10 views2 pages

Odd Even

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

import java.util.

*;

class odd_even

public static Scanner sc=new Scanner (System.in);

public static void main (String args[])

int n,i;

System.out.println("Enter the number of elements");

n=sc.nextInt();

int arr[]=new int [n];

System.out.println("enter all number of elements");

for(i=0;i<n;i++)

arr[i]=sc.nextInt();

System.out.println("odd numbers:");

for(i=0;i<n;i++)

if(arr[i]%2!=0)

System.out.println(arr[i]+"");

System.out.println("");

System.out.println("even numbers");

for(i=0;i<n;i++)

if(arr[i]%2==0)

{
System.out.println(arr[i]+"");

}}

You might also like