Multiple choice technology programming languages

What gets printed? int i = 3; if (!i) i++; i++; if (i==3) i+=2; i+=2; printf("%d\n", i);

  1. 6

  2. 7

  3. 3

  4. 5

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

The if statements control only the immediately following statement when braces are absent. The !i check is false (i=3, so !i=0), so that i++ is skipped. i becomes 4, then the i==3 check is false, skipping i+=2. Finally i+=2 executes, making i=6.