Intermediate Code questions

Q52

GATE CS 2025 CS-1Intermediate CodeNAT2 marks
Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ________. (Answer in integer)
1001: i = 1
1002: j = 1
1003: t1 = 10*i
1004: t2 = t1+j
1005: t3 = 8*t2
1006: t4 = t3-88
1007: a[t4] = 0.0
1008: j = j+1
1009: if j <= 10 goto 1003
1010: i = i+1
1011: if i <= 10 goto 1002
1012: i = 1
1013: t5 = i-1
1014: t6 = 88*t5
1015: a[t6] = 1.0
1016: i = i+1
1017: if i <= 10 goto 1013
Show answer without attempting

Answer: 6

Q21

GATE CS 2025 CS-2Intermediate CodeMCQ1 mark−1/3 if wrong
Consider the following statements about the use of backpatching in a compiler for intermediate code generation:

(I) Backpatching can be used to generate code for Boolean expression in one pass.
(II) Backpatching can be used to generate code for flow-of-control statements in one pass.

Which ONE of the following options is CORRECT?
Show answer without attempting

Answer: C

Q39

GATE CS 2024 CS-1Intermediate CodeMCQ2 marks−2/3 if wrong
Consider the following pseudo-code.
L1:t1=−1L1: t1 = -1
L2:t2=0L2: t2 = 0
L3:t3=0L3: t3 = 0
L4:t4=4∗t3L4: t4 = 4 * t3
L5:t5=4∗t2L5: t5 = 4 * t2
L6:t6=t5∗ML6: t6 = t5 * M
L7:t7=t4+t6L7: t7 = t4 + t6
L8:t8=a[t7]L8: t8 = a[t7]
L9:if t8<=max goto L11L9: \text{if } t8 <= max \text{ goto } L11
L10:t1=t8L10: t1 = t8
L11:t3=t3+1L11: t3 = t3 + 1
L12:if t3<M goto L4L12: \text{if } t3 < M \text{ goto } L4
L13:t2=t2+1L13: t2 = t2 + 1
L14:if t2<N goto L3L14: \text{if } t2 < N \text{ goto } L3
L15:max=t1L15: max = t1
Which one of the following options CORRECTLY specifies the number of basic blocks and the number of instructions in the largest basic block, respectively?
Show answer without attempting

Answer: D

Q43

GATE CS 2024 CS-2Intermediate CodeMCQ2 marks−2/3 if wrong
Consider the following expression: x[i]=(p+r)∗−s[i]+u/wx[i] = (p + r) * -s[i] + u/w. The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).

Which one of the following options fills in the missing entries CORRECTLY?
Question figure
Show answer without attempting

Answer: A

Q50

GATE CS 2021 CS-1Intermediate CodeNAT2 marks
Consider the following C code segment:
a = b + c;
e = a + 1;
d = b + c;
f = d + 1;
g = e + f;
In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The number of nodes in the DAG is ______.
Show answer without attempting

Answer: 6

Q13

GATE CS 2021 CS-2Intermediate CodeMSQ1 mark
In the context of compilers, which of the following is/are NOT an intermediate representation of the source program?
More than one option can be correct.
Show answer without attempting

Answer: D

Q12

GATE CS 2017 CS-1Intermediate CodeMCQ1 mark−1/3 if wrong
Consider the following intermediate program in three address code
p = a - b
q = p * c
p = u * v
q = p + q
Which one of the following corresponds to a static single assignment form of the above code?
Show answer without attempting

Answer: B

Q19

GATE CS 2016 CS-1Intermediate CodeNAT1 mark
Consider the following code segment.
x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;
The minimum number of total variables required to convert the above code segment to static single assignment form is ________.
Show answer without attempting

Answer: 10.0

Q47

GATE CS 2015 CS-1Intermediate CodeNAT2 marks
The least number of temporary variables required to create a three-address code in static single assignment form for the expression q+r/3+s−t∗5+u∗v/wq + r/3 + s - t * 5 + u * v/w is ________.
Show answer without attempting

Answer: 8

Q28

GATE CS 2015 CS-2Intermediate CodeMCQ1 mark−1/3 if wrong
In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is TRUE?
Show answer without attempting

Answer: C

Q44

GATE CS 2015 CS-2Intermediate CodeMCQ2 marks−2/3 if wrong
Consider the intermediate code given below.
(1)  i = 1
(2)  j = 1
(3)  t1 = 5 * i
(4)  t2 = t1 + j
(5)  t3 = 4 * t2
(6)  t4 = t3
(7)  a[t4] = -1
(8)  j = j + 1
(9)  if j<=5 goto (3)
(10) i=i+1
(11) if i<5 goto (2)
The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are
Show answer without attempting

Answer: B

Q34

GATE CS 2014 CS-2Intermediate CodeMCQ2 marks−2/3 if wrong
For a C program accessing X[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits.
t0 = i * 1024
t1 = j * 32
t2 = k * 4
t3 = t1 + t0
t4 = t3 + t2
t5 = X[t4]
Which one of the following statements about the source code for the C program is CORRECT?
Show answer without attempting

Answer: A

Q17

GATE CS 2014 CS-3Intermediate CodeMCQ1 mark−1/3 if wrong
One of the purposes of using intermediate code in compilers is to
Show answer without attempting

Answer: C

0/130 correct0 marks

Related topics in Compiler Design