This is a program to check if a number is even or odd in the ‘C’ programming language.
We can do this by first getting the number from the user.
The logic:
A number will be even if it is divisible by 2. Elaborating more, when the number is divided by 2, if there is a remainder of 0, the number is even , else it is odd.
We will make use of the ‘if-else’ statement to do this program.
Here is the code:
// Online C compiler to run C program online
#include <stdio.h>
int main() {
// Write C code here
printf("Checking if a number is odd or even");
int a;
scanf("%d", &a); // The user inputs the number
if (a % 2 == 0) //if loop
printf("Number is even");
else
printf ("Number is odd");
return 0;
}
This will be the output of the program

Checking if a number is odd or even
50
Number is even
=== Code Execution Successful ===
As always, this code can be compiled and run at this online compiler
Note: This code is not ChatGPT generated 🙂
This is the next post for BlogchatterHalfMarathon by @blogchatter
(Visited 22 times, 1 visits today)