Computer Science, asked by chiragjhunjhunwala2, 4 months ago

write a java program to say whether the number is odd or even

Answers

Answered by sameer7815
1

import java.io.*;

class oddeven

{

public static void main(String args[]) {

DataInputStream ins= new DataInputStream(System.in); System.out.println("enter a no");

int n= Integer.parseInt(ins.readLine()); if ( n%2 ==0) { System.out.println(" even no");

}

else

{ System.out.println("odd no");

}

}

}

hope it helps

please mark as brainliest

u can also make this program by using scanner class...

Answered by gunjotsingh0909
1

Answer:

import java.util.*;

class odd and even

{

public static void main(string args[])

{

scanner sc = new scanner(system.in)

system.out.println("enter the value of n");

intn= sc.nextInt();

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

{

if(i℅2==0)

{

system.out.println("even");

}

else

system.out.println("odd");

}

}

}

Similar questions