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.
Odd Numbers
An Odd Number is the one which is not Divisible by 2. The condition to check Odd Numbers is num%2!=0
Even Numbers
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import java.io.*; import java.util.*; class EvenAndOdd { public static void main(String[] arguments) { int num1; 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"); else System.out.println("\n" + num1 + " is an Odd Number"); } } |
Also Read: Java Program To Calculate Sum of Odd Numbers
Output

In case you have any doubts to Check Even or Odd Number in Java Programming, mention it below.