Multiple choice technology programming languages

#include int main() { int i=0; for(;i--;); printf("%d",i); }

  1. 0

  2. 1

  3. Infinite loop

  4. -1

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

The for loop has an empty body and uses i-- as its condition. The condition is checked before each iteration. Starting with i=0, the condition i-- evaluates to 0 (false) but decrements i to -1 as a side effect. Since the condition is false, the loop body never executes, and the loop terminates. The printf then outputs -1.