on Leave a Comment

Java Program to check Even or Odd Number

This java program checks whether a number even or odd. Even number is a number that is completely divided by 2 and odd number cannot completely divide by 2.

Java Program to check Even or Odd Number

import java.util.Scanner;
public class EvenOdd
{
        public static void main(String[] args)
        {
                Scanner sc = new Scanner(System.in);
                System.out.println("Enter a number");
                int x = sc.nextInt();
                if(x%2 == 0)
                        System.out.println(x+" is a even number");
                else
                        System.out.println(x+" is a odd number");
        }
}

OUTPUT 1:

Enter a number
59
59 is a odd number

OUTPUT 2:

Enter a number
86
86 is a even number

0 comments:

Post a Comment