Ternary Operator:-
In C++, the ternary operator (also known as the conditional
operator) can be used to replace if – else in certain
scenarios.
A ternary operator evaluates the test condition and executes
a block of code based on the result of the condition.
Its syntax is
condition ? expression1 : expression2;
Here, condition is evaluated and
• if condition is true, expression1 is executed.
• And, if condition is false, expression2 is executed.
The ternary operator takes 3
operands (condition, expression1 and expression2). Hence,
the name ternary operator.
Example : C++ Ternary Operator