Check Whether a Number is Even or Odd
Identify whether a number is even or odd.
Example
int number = 5;
// Find out if the number above is even or odd
if (number % 2 == 0) {
System.out .println(number + " is even.");
} else {
System.out .println(number + " is odd.");
}
|