C Program to Check Whether Number is Even or Odd Using Conditional Operator
This C program checks whether a given number by user is even or odd using Conditional Operator.
C Source Code: Even or Odd Using Conditional Operator
#include<stdio.h>
int main()
{
int number;
printf("Enter number: ");
scanf("%d", &number);
/* Checking Even or Odd */
number%2?printf("ODD"):printf("EVEN");
return 0;
}
Output
Run 1: --------------- Enter number: 11 ODD. Run 2: --------------- Enter number: 24 EVEN