← BYTES
C·Starter·Ref: 7.1.17

What does the ternary operator `cond ? a : b` evaluate to?

Have a question about this video? Mention reference 7.1.17 when you contact us.

a.Both a and b, always
b.a if cond is true (nonzero), otherwise b
c.cond itself
d.Always a syntax error in C
The conditional (ternary) operator is a compact inline if/else: it evaluates cond, and the whole expression's value is a when cond is nonzero (true) and b otherwise.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES7117#C