Ternary Operators

Ternary operator is only one operator present in C. The ternary operator is combination of two special characters those are ? and :. The ternary operator is exactly replaces the if else control block. Shortest form of if else is ternary operator.

Syntax of ternary operator.
(conditional statement)? statement1 : statement2;

First the conditional statement is checked if it is true then the statement1 is executed if is is false statement2 is executed.

Ternary Operator Demp program


Output