GATE Computer ScienceHardGATE CSE

Statements: 1: a = 1; 2: b = 2; 3: c = a + b; 4: d = c * 2; 5: if d > 10 goto 8; 6: e = a + d; 7: goto 9; 8: e = b + 1; 9: print e. Which variables are live immediately before statement 5?

  1. A. {a, b, d}
  2. B. {b, d}
  3. C. {a, d}
  4. D. {a, b, c, d}

Correct answer: A. {a, b, d}

Before 5, d is used there; a is used on the path through 6, b on the path through 8 — so the live set is {a, b, d} (c is dead after 4).

More Compiler Design questions

Exams that ask this topic