C program to check whether a Number is Even or Odd

In this program, you will find whether numbers entered by users are even or odd. if the number is even, you will print the number is even and if the number is odd, print the number is odd.

Even numbers are integers that are exactly divisible by 2 and have no remainder. for Example 2, 10. -16.

even odd program in c

#include<stdio.h>
int main()
{
  int a;
  printf("\n enter the number:");
  scanf("%d",&a);
  if(a%2==0)
  {
     printf(" %d is even number",a);
  }
  else
  {
      printf("%d is odd number",a);
  }
  return 0;
}

output

enter the number:15
15 is odd number
enter the number:10
10 is even number

explanation of Even or Odd program

  • Take a number from user and store it in variable a.
  • Now check whether the number is completely divisible by 2 or not.
  • If the number is completely divisible by 2 and it will give a reminder 0, then if a part will get executed and it will print that the number is even.
  • If the remainder is not zero then else part will get executed and it will print, the number is odd.