Multiple choice technology programming languages

Find the output of this program. main() { int i=5; printf(“%d”,i=++i ==6); }

  1. 6

  2. 1

  3. 5

  4. Compiler error

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

The expression i=++i==6 is evaluated as follows: ++i pre-increments i to 6, then 6==6 yields 1 (true), and finally i=1 assigns 1 to i. The printf prints the final value of i, which is 1. Option A incorrectly assumes the comparison result isn't assigned.