A Program to Check Whether a Number is Even or Odd
In this example, we are giving a program which is useful to check whether a number given by the user is even or odd.
Program to check even or odd:
#include <stdio.h>
int main()
{
int number;
printf("Enter an integer: ");
scanf("%d", &number);
// True if the number is divisible by 2
if(number % 2 == 0)
printf("%d is even.", number);
else
printf("%d is odd.", number);
return 0;
}
Output:
Enter an integer number: -53 -53 is odd.