**Even number**is an integer number which is "evenly divisible" by two. That means if the integer is divided by 2, it yield no remainder. For example, even numbers are, 2, 4, 6, 8, 10, etc.

**Odd number**is an integer number which is not a multiple of two. That means if it is divided by 2 the result is fraction. For example, 1, 3, 5, 7, 9, etc.

In the given program, we get a number from command line and calculate

**no%2**. If it is zero then the number is even number otherwise that is odd number.**PROGRAM**

class EvenOdd { public static void main(String[] args) { int num = Integer.parseInt(args[0]); if (num % 2 == 0) { System.out.println("Number is Even number."); } else { System.out.println("Number is Odd number."); } } }

**OUTPUT 1**

C:\>javac EvenOdd.java C:\>java EvenOdd 12 Number is Even number.

**OUTPUT 2**

C:\>javac EvenOdd.java C:\>java EvenOdd 45 Number is Odd number.

## No comments:

## Post a comment