PROGRAM FOR EVEN ODD NUMBER
The logic in this program, the modulus operation determines the remainder of the division operation of the two numbers, it seems logical that the modulus operator be used to determine even or odd numbers.
An even number, by definition, is any number divisible by two. Therefore, if a number which returns a zero for a remainder when modulo 2.
More simply,a number "x" is even if "x % 2" equals zero. For example, this code defines a function that takes an integer and returns an integer (0 or 1) based on whether or not the number is even.
public class OddEven
public static void main(String args)
System.out.println("Enter an integer to check if it is odd or even ");
Scanner x = new Scanner(System.in);
x = in.nextInt();
if ( x % 2 == 0 )
System.out.println("Given Number is an even .");
System.out.println("Given Number is an odd ");
Output :Even Odd