C Program to Check Whether a Number is even or odd: For checking whether the number is even or odd using simple equation. Even numbers are 0, 2, 4, 6, …. Even number has reminder 0 so we find reminder and check number is even or odd.

Example:
number=10
rem=10%2 => rem=0
The number is even

Algorithm to check number is even or odd

  1. Take input. No
  2. Find reminder = number % 2
    If reminder == 0
    Print number is even
    Else
    Print number is odd

C Program to Check Whether a Number is even or odd

#include<stdio.h>
void main()
{
int number;
printf("Enter a Number \n");
scanf("%d", &number);
if(number % 2 == 0)
{
printf("The number %d is Even", number);
}
else
{
printf("The number %d is Odd",number);
}
printf("\n");
}

Output:

C Program to Check Whether a Number is even or odd

Write A Comment