C Program to Check Whether a Number is Even or Odd - IProgramX

Q. Write a program to accept an integer and check if it is even or odd


Program

#include <stdio.h>
int main()
{
    int number;
    printf("Enter an integer: ");
    scanf("%d", &number);
    if(number % 2 == 0)
printf("%d is even.", number);
else
printf("%d is odd.", number);
}

Output:

Enter an integer: 4
4 is even.

Post a Comment

0 Comments