Monday, August 10, 2020

Write a Program to check Even or Odd number in Java.

Check Even or Odd number in Java.


Check Even or Odd number in Java.

Java program to check whether a number is even or odd, if it's divisible by two, then it's even, otherwise, odd.

EXAMPLE :-

import java.util.Scanner;

class CEO
{
public static void main(String args[])
{
int num;
System.out.println("Enter an Integer Number ::");

Scanner input = new Scanner(System.in);
num = input.nextInt();

if ( num % 2 == 0 )
System.out.println("It is Even");
else
System.out.println("It is Odd");
}
}


OUTPUT

Enter an Integer Number ::
28 It is Even

No comments:

Post a Comment

Please do not any spam link in Comment Box