C Program to Check if a given Integer is Odd or Even

An integer is even if it is evenly divisible by 2 and odd if it is not then it is even.
#include <stdio.h>
void main()
 int val, rem;
 printf("Enter an integer : ");
 scanf("%d", &val);
 rem = val % 2;
 if (rem == 0)
 printf("%d is an even integer\n", val);
 printf("%d is an odd integer\n", val);

Leave a Comment

Your email address will not be published. Required fields are marked *