C Program to Check a number is Even or Odd

In C programming, you can determine whether a number is odd or even using the modulo operator (%). The modulo operator calculates the remainder when one number is divided by another. If the remainder is 0, the number is even; otherwise, it’s odd.

Here’s a simple example of a C program that checks whether a given number is odd or even:

I

Program :

#include<stdio.h>
#include<conio.h>
main()
{
int a;
printf(“Enter the Number : “);
scanf(“%d”,&a);
if(a==0)
{
printf(“You enter zero,enter different number.”);
}
else if((a%2)==0)
{
printf(“%d is a Even Number.”,a);
}
else
{
printf(“%d is a Odd Number.”,a);
}
}

Output :

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights