GATE Computer ScienceModerateGATE CS (PYQ pattern)

In 1: a = 1; 2: b = 2; 3: if p > 0 goto L1; 4: a = a + 1; 5: goto L2; 6: L1: b = b + 1; 7: L2: c = a + b; 8: if c > q goto L3; 9: a = c; 10: goto L2; 11: L3: return a, how many definitions of a reach the start of statement 7 (L2: c = a + b)?

  1. A. 3
  2. B. 2
  3. C. 4
  4. D. 5

Correct answer: A. 3

Definitions of a reaching 7: statements [1, 4, 9]; the loop 9 → 7 brings a = c back as well.

More Compiler Design questions

Exams that ask this topic