Practice mode C Language

Which is the only ternary operator in C, taking three operands?

Correct answer D. ?: (conditional operator)

Explanation

The conditional operator cond ? a : b takes three operands: it evaluates cond, then evaluates and yields exactly one of a or b. && and the comma operator are binary, taking two operands, and -> takes a pointer and a member name. Because only the chosen branch is evaluated, ?: can safely guard an expression, as in p ? p->x : 0.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.