Conditional Operators in C

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

Syntax


expression ? statement1:statement2							
							

Example


#include<stdio.h> 
void main()
{
  int age;
  printf(" Please Enter your age\n ");
  scanf("%d",&age);
 (age >= 18) ? printf("Eligible") : printf("Not Eligible"); 
}							
							
Share Share on Facebook Share on Twitter Share on Google+ Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit