Write a C Program to find whether the number is even or odd

Write a C Program to find whether the number is even or odd

Here is the C Program to find whether the number is even or odd. The modulus function is used here. The modulus of even number with two will be equal to zero (a%2 == 0), this logic is used to find whether the number is odd or even.

#include<stdio.h>
#include<conio.h>
int main()
{         int a;
           printf(“Enter the number:”);
           scanf(“%d”,&a);
           if (a%2==0)
          {           printf(“%d is even”,a);
           }
           else
          {           printf(“%d is odd”,a);
           }
           return 0;
}
Output

You may also like...

Leave a Reply