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.

#include<stdio.h>

int main() {

   int num;

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

   if (num % 2 == 0) {
       printf("Number is even :%d", num);
   } else {
       printf("Number is odd :%d", num);
   }

   return 0;
}

Output:

Enter a number :14                                                                                                                                                  
Number is even :14