Java Code To Check a Given Number Is Odd or Even

March 10, 2023

Program:

public class Odd 
{
	public static void main(String[] args) 
	{
		int x = 16;
		int y = x % 2;
		if (y == 0) 
		{
			System.out.println("The given number is Even ");
		} 
		else 
		{
			System.out.println("The given number is odd ");
		}
	}
}

Compile:

javac Odd.java
java  Odd 

Output:

The given number is Even

You Might Also Like