Q-28- Input an integer through the keyboard. Write a java program to find out whether it is an odd number or even number.
INPUT :
import java.util.Scanner;
public class NCM {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int num;
System.out.println("Enter The Number :");
num=sc.nextInt();
if(num%2==0)
{
System.out.println("It Is An Even Number.");
}
else
{
System.out.println("It Is An Odd Number.");
}
}
}
OUTPUT :
Enter The Number :
4
It Is An Even Number.
INPUT :
import java.util.Scanner;
public class NCM {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int num;
System.out.println("Enter The Number :");
num=sc.nextInt();
if(num%2==0)
{
System.out.println("It Is An Even Number.");
}
else
{
System.out.println("It Is An Odd Number.");
}
}
}
Enter The Number :
4
It Is An Even Number.
Enter The Number :
5
It Is An Odd Number.
No comments:
Post a Comment