Consider the intermediate code given below: i = 1 j = 1 t1 = 5 * i t2 = t1 + j…
2015
Consider the intermediate code given below:
i = 1
j = 1
t1 = 5 * i
t2 = t1 + j
t3 = 4 * t2
t4 = t3
a[t4] = −1
j = j + 1
if j <= 5 goto (3)
i = i + 1
if i < 5 goto (2)
The number of nodes and edges in the control-flow graph constructed for the above code, respectively, are
- A.
5 and 7
- B.
6 and 7
- C.
5 and 5
- D.
7 and 8
Attempted by 30 students.
Show answer & explanation
Correct answer: B
To construct the Control Flow Graph (CFG), identify basic blocks starting at entry and jump targets. The code forms 5 basic blocks: initialization, loop body, inner check, outer update, and outer check. There are 7 edges representing flow between these blocks, including back-edges for loops and the exit path.One Node for start and another for end .

A video solution is available for this question — log in and enroll to watch it.