The Conditional (?:) Operator

The syntax of the conditional operator in C is:
exp1 ? exp2 : exp3;
where exp1,exp2 and exp3 are expression.Here, exp1 is evaluated first. If it is true(non zero), then exp2 is evaluated and it becomes the value of the expression. On the other hand if exp1 is false, then expression three is evaluated and its value becomes the value of the expression. The conditional operator need not be used only in arithmetic statement.

No comments:

Post a Comment