C program to check even or odd number

C program to check even or odd number

How can we check even or odd number in C? Here we are using modulus operator to check and "printf" method to print the result.

Even or odd in C :



#include <stdio.h>
int main()
{
  int n;

  printf("Enter an integer : ");
  scanf("%d", &n);

  if (n%2 == 0)
    printf("Even\n");
  else
    printf("Odd\n");

  return 0;
}
  

Output :