C Programming Lab Manual – 10

Write a C program to Check Whether a is Even or Odd.

Function Main
    Declare Integer num
    Output "Enter a integer: "
    Input num
    If num % 2 == 0
        Output "number is even"
    False:
        Output "number is odd"
    End
End





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

Enter an integer: 4
4 is even.

Enter an integer: 5
5 is odd.