public class EvenOdd {
public static void main(String[] args) {
int num = 7;
if (num % 2 == 0)
System.out.println(num + " is Even");
else
System.out.println(num + " is Odd");
}
}
num stores the number to check.
% (modulus) finds the remainder when dividing by 2.
If remainder = 0 → number is even, otherwise odd.