Even or Odd Program in Java using If Else

We will create Even or Odd Program in Java using if else. In this program

Program : Write a Program to input any number and check number is even or odd.

// Program to check Number is Even or Odd If Else.
import java.util.*;
class EvenOdd
{
	public static void main(String ar[])
	{
		Scanner sc = new Scanner(System.in);
		int num;
		System.out.print("Enter a Number: ");
		num = sc.nextInt();
		if(num%2==0)
		{
			System.out.println("Entered Number is Even...");
		}
		else
		{
			System.out.println("Entered Number is Odd...");
		}
	}
}
Enter a Number: 4
Entered Number is Even... 

Be the first to comment

Leave a Reply

Your email address will not be published.


*