C Language program to take a number as input and tells its even or odd number
Following program shows you how to take a number as input and tells its even or odd number.
This program divides input by 2, If remainder is zero it prints even otherwise it prints odd
#include <stdio.h>
int main() {
int input;
printf("Please enter a number:");
scanf("%d", &input);
if (input % 2 == 0) {
printf("even");
} else {
printf("odd");
}
}
Output:
Example1:
Please enter a number: 3
odd
Example2:
Please enter a number: 80
even