C Programming - Old Questions

6. Write a program to check whether a number entered is even or odd.

5 marks | Asked in 2075

#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;
}