Java Program To Find Even Or Odd

Sharing is healthy !!

Today you will learn and execute java program to find even or odd.

Here in the below program modulus operator is used to find the number entered is even or odd.

If the remainder of the modulus operator is equal to zero then the number entered is even number else the number entered is odd number.

example: JAVA PROGRAM TO FIND EVEN OR ODD

Also Read – Add Two Numbers With Bitwise Operator

import java.util.Scanner;

public class EvenOdd {

public static void main(String[] args) {

int a;
System.out.println("Please enter a number to check even or odd:");
Scanner sc = new Scanner(System.in);
a = sc.nextInt();

if(a % 2 == 0){
System.out.println("Entered number is an even number");
}
else{
System.out.println("Entered number is an odd number");
}
}
}

Output:

Java Program To Find Even Or Odd

Sharing is healthy !!

Leave a Reply

Your email address will not be published.