Online Snippets Library

Check if a given number is even or odd

To Check number is even or odd in C, We need use conditional statement if-else in C.

C Program
#include 

int main() {
   int evennum = 44;
   int oddnum  = 41;
   
   if (evennum % 2 == 0)
      printf("%d is even\n", evennum);
   
   if (oddnum % 2 != 0 )
      printf("%d is odd\n", oddnum);
   
   return 0;
}

Output

44 is even 41 is odd