GATE Computer ScienceModerateNIELIT Scientist B

Consider this three-address code: 1: i = 0; 2: s = 0; 3: if i >= n goto 9; 4: t = a[i]; 5: if t < 0 goto 7; 6: s = s + t; 7: i = i + 1; 8: goto 3; 9: print s. Into how many basic blocks is it partitioned?

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

Correct answer: C. 6

The leaders are statements 1, 3, 4, 6, 7 and 9 (first statement, jump targets, and statements after jumps), giving 6 blocks.

More Compiler Design questions

Exams that ask this topic