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
Post A Comment:
0 comments: