Conditional Operator
The Conditional Operator is a ternary operator which requires three operands for its operation. The Conditional Operator is denoted by ?:
symbol. There are three parts in Conditional Operator. First part is Expression or Condition, Second part is true block and third part is false block.
Syntax:
(Expression or Condition) ? (true block) : (false block)
Example:
Consider A = 20 and B = 10
(A>B) ? A : B would result A i.e 20
Program example of conditional operator
//An example of conditional operator
#include<stdio.h>
int main()
{
int A=20, B=10;
printf("%d",((A>B) ? A : B));
return 0;
}
Output
20