What is conditional operator? Explain with example.


Conditional Operator:
The conditional operator is unique in that it has three operands separated by two unconnected operatoe symbols. All other C++ operator are either unary or binary.
On the “Abbreviated precedence chart for C++ operators” the conditional operator has the word “trinary” in the comments column. This prefix “tri” means three, thus three operands.

Example:
                A =10;
                B = 15;
X =(A>B)? A:B;
if = (A>B);
X = A
else
X =B?


1 comment: