C Program to Check Whether a Number is Even or Odd: To check whether a given number is EVEN or ODD, we are checking modulus by dividing the number by 2, if the modulus is 0, then it will be completely divisible by 2 hence number will be EVEN or it will be ODD.
C Program to Check Whether a Number is Even or Odd
#include <stdio.h>
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);
return 0;
}
Output of Program
Enter an integer: 5
5 is odd.