? :,Conditional Expression or ternary operator, Check whether Number is Odd or Even

C Programming Language / Operators and Enums in C Language

1325

Program:

#include"stdio.h"
int main()
{
int num,flag=0;

printf("Enter the Number : ");
scanf("%d",&num);

flag = ((num%2==0)?1:0);

if(flag==1)
   printf("Even \n");
else
   printf("Odd \n");
}

Output:

Enter the Number : 45
Odd
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.