Write a program to check whether a given number is even or odd using the modulus operator.

#include <stdio.h>

int main() {
int num;

// Take input from the user
printf(“Enter a number: “);
scanf(“%d”, &num);

// Check if the number is even or odd using modulus operator
if (num % 2 == 0) {
printf(“%d is even.\n”, num);
} else {
printf(“%d is odd.\n”, num);
}

return 0;
}

Explanation: The program prompts the user to enter an integer. The modulus operator % is used to check whether the remainder when dividing the number by 2 is zero or not. If the remainder is zero (num % 2 == 0), the number is even; otherwise, it is odd.