Multiple choice technology programming languages

What would be the output of the following program? main() { static int a[20]; int i =0 ; a[i]=i++; printf("\n%d %d %d",a[0],a[1],i); }

  1. 1 0 1

  2. 0 0 1

  3. 1 2 3

  4. Compile error

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

The statement a[i]=i++ is undefined behavior in C because it modifies i and also uses its value in the same expression without a sequence point. However, the expected output is 0 0 1 because a[0] gets the original value of i (which is 0) before the increment, and a[1] remains uninitialized (0 for static arrays). The i variable becomes 1.