Conditional and Ternary Operator
It is sometimes called ternary operator because it takes three operands in the operation. The expression syntax is:
(Conditional Expression) ? (Expression1) : (Expression2);
If the conditional expression is evaluated to true (if its value is non-zero) then the expression1 is executed otherwise expression2 is executed.
Example:
int x,y;
scanf("%d",&x);
y=(x>5?3:4);
The last statement will store 3 in variable y if x is greater than 5, otherwise 4 in y. It is not necessary that the conditional operator should be used only in arithmetic statements, they can also be used with other statements as printf().
Example
(i= =1) ? printf("RAM") : printf("MOHAN");
The conditional operator can also be nested.
Example
big = (a > b ? (a > c ? a : c) : (b > c ? b : c ));