C Program to check a number is even or odd


In this program, You will learn how to check a number is even or odd in C.


if (num % 2 == 0) { }


Example: How to check a number is even or odd in C

Run it Now
#include<stdio.h>

int main() {

   int num;

   printf("Enter a Number :");
   scanf("%d", &num);

   if (num % 2 == 0) {
       printf("\nNumber is Even :%d", num);
   } else {
       printf("\nNumber is Odd :%d", num);
   }

   return 0;
}

Output:

Enter a Number :14
Number is Even :14