NPTEL Online Certification Courses Indian Institute of Technology Kharagpur
NPTEL Online Certification Courses Indian Institute of Technology Kharagpur
Compiler Design
Assignment- Week 11
TYPE OF QUESTION:MCQ
Number ofquestions:13 Total mark: 13 X 1 = 13
(A) Null
(B) Some value
(C) Constant
(D) None of the other options
Ans: B
Solution:
3. When generating code for the Boolean expression "(x ≥ y) AND (p ≠ q)", which locations
are left for back patching?
a) Falselist of x≥y
b) Falselist of x≥y and falselist of p q
c) Falselist of x≥y, falselist of p q, truelist of p q
d) Truelist of x≥y, falselist of x≥y, truelist of p q, falselist of p q
Ans: B
Explanation:
(A) B1.truelist
(B) B1.falselist
(C) B2.truelist
(D) B2.falselist
Ans: B
Explanation:
6. For the rule B B1 and B2, the operation "B1.false = B.false" requires two passes as
7. In the rule C→C1 AND NC2 the non terminal N is used to remember the start address of:
(A) C
(B) C₁
(C) Both C₁ and C
(D) None of the other options
Ans: B
Explanation:
(A) then-part
(B) else-part
(C) both then- and else-part
(D) None of the other options
Ans: A
Explanation:
9. In the rule S if B then M S1, M holds the start address for
(A) S1
(B) S
(C) B
(D) None of the other options
Ans: A
Explanation:
10 For three address code generation of rule “S while M1 B do M2 S1”, B.falselist is
. backpatched with
(A) M1.quad
(B) M2.quad
(C) Cannot be backpatched at this point
(D) None of the other options
Ans: C
Explanation:
11.
Ans: B
Solution:
In TAC, arrays are accessed using their base address and an index offset.
The address of an array element is computed as:
Address=Base Address+(Index×Element Size)
This ensures efficient memory access and supports multi-dimensional arrays using similar
calculations.
12.
In the rule S → while M1 B do M2 S1, the non-terminal M2 is used to remember the start
address of:
(A) S
(B) B
(C) S1
(D) None of the other options
Explanation:
• (A) S → Incorrect, because S is the entire statement, not just the body.
• (B) B → Incorrect, because B is a condition, not the loop body’s start point.
13.
Ans: B
END of Assignment