Write a java program to read an integer and find whether the number is odd or even.

Program Code in JAVA:
import java.io.*;
class odd
{
public static void main(String args[])throws IOException
{
BufferedReader din = new BufferedReader(new InputStreamReader(System.in));
int n;
system.out.println(“enter a number:”);
n= Integer.parseInt(din.readLine());
if(n%2==0)
system.out.println(n+"is an even no");
else
system.out.println(n+"is an odd no:");
}
}


Program Output:
c:\java>javac odd.java
c:\java>java odd
Enter a no: 67
67 is an odd no
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: