In this post,we will see how to check if number is even odd. It is one of the basic programs of Java programming language.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import java.util.Scanner; public class EvenOddFinder { public static void main(String args[]) { int num; Scanner scanner = new Scanner(System.in); System.out.print("Enter a Number : "); num = scanner.nextInt(); if(num%2 == 0) { System.out.print(num+" is an Even Number"); } else { System.out.print(num+" is an Odd Number"); } } } |
Output:
Enter a Number : 22
22 is an Even Number
22 is an Even Number
That’s all about Even odd program in java.
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.