The Conditional Operator in C is also called as Ternary operator. In C Programming, Conditional Operator is used in decision making process. This operator returns the statement depends upon the given expression result. Let’s see the syntax of the conditional operator and example of conditional operator in c programming.
Sr.No |
Operator |
Descriptions |
---|---|---|
01 |
? |
conditional |
expression ? statement1:statement2
#include<stdio.h>
void main()
{
int age;
printf(" Please Enter your age\n ");
scanf("%d",&age);
(age >= 18) ? printf("Eligible") : printf("Not Eligible");
}