Ternary Operator in C

What is Ternary Operator in C ?

It is also known as conditional operators. It requires three operands.

General Syntax :

expression1 ? expression 2: expression 3

Explanation:

Here expression 1 must be a condition. Expression 1 will always evaluated. If the condition is true then it will go to expression 2,
but the condition is false it will go for the expression 3.

Example 1:

Example 2: