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. Required fields are marked *

Shopping Basket
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare
Verified by MonsterInsights