Thursday, February 7, 2008

Check a Number : Even or Odd?

A very simple program to find whether a number is odd or even. As we have taken 4 to check whether it is even or not. It is even because when we divide it by 2 then the reminder will be 0.

class Evenodd
public static void main(String args[])
int a = 4;
if((a % 2) == 0)
System.out.print("Number is even");
System.out.println("Number is odd");