Multiple choice

What will be the output of the given function?void main() { int a=1,b=2,c=3,d=4; printf("%d",!a?b?!c:!d:a); }

  1. 1

  2. 0

  3. No output

  4. Error

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The nested ternary evaluates as: !a ? (b ? !c : !d) : a. Since a=1, !a=0 (false), so we take the rightmost branch and return a, which is 1. The nested ternarys on the left side (!c and !d) are never evaluated due to short-circuiting.