Find Even or Odd Number in Java Programming
Here’s a Program To Find Even or Odd Number in Java Programming Language. It is important to use the Modulus Operator to Check if the Number is Even or Odd.
An Odd Number is the one which is not Divisible by 2. The condition to check Odd Numbers is num%2!=0
An Even Number is the one which is Divisible by 2.The condition to check Odd Numbers is num%2==0
Also Read: Java Code To Calculate Sum of Even Numbers
Program To Find Even and Odd Number in Java
public static void main(String arguments)
System.out.println("\nEnter A Number");
Scanner sc = new Scanner(System.in);
num1 = sc.nextInt();
if(num1%2 == 0)
System.out.println("\n" + num1 + " is an Even Number");
System.out.println("\n" + num1 + " is an Odd Number");
Also Read: Java Program To Calculate Sum of Odd Numbers
In case you have any doubts to Check Even or Odd Number in Java Programming, mention it below.