The Conditional Operator

The expression ?: operator is called conditional operator and takes the form.
Exp1? Exp2?:Exp3;

Exp1,Exp2&Exp3 are expressions.
Exp1 is evaluated for true condition, if it is found true Exp2 becomes value of the expression, if false Exp3 becomes value of the expression. For example consider the following statements.

A=10
N=(a>5)?15:0;
N will be assigned the value 15.

No comments:

Post a Comment