Skip to main content

10 Multiple Choice Questions (MCQs) related to Intermediate Code Generation

10 Multiple Choice Questions (MCQs) related to Intermediate Code Generation, useful for UGC NET, SET, and GATE exams:


1. What is the main purpose of intermediate code generation in a compiler?

A) Convert high-level code to machine code
B) Generate an intermediate representation for optimization and portability
C) Detect syntax errors
D) Allocate memory for variables

Explanation:
Intermediate code generation creates an intermediate representation (IR) that is machine-independent, allowing for optimization and easier translation to machine code.

Answer: B) Generate an intermediate representation for optimization and portability


2. Which of the following is NOT an intermediate representation format?

A) Abstract Syntax Tree (AST)
B) Three-Address Code (TAC)
C) Postfix Notation
D) Machine Code

Explanation:
Machine code is the final output of compilation, not an intermediate representation.

Answer: D) Machine Code


3. Which of the following is a characteristic of an intermediate representation?

A) It is directly executed by the processor
B) It is machine-independent
C) It is a high-level language
D) It does not allow optimization

Explanation:
Intermediate code is machine-independent, making it useful for compiler optimization and target code generation.

Answer: B) It is machine-independent


4. What is the most common form of intermediate representation used in compilers?

A) High-Level Code
B) Three-Address Code (TAC)
C) Binary Machine Code
D) Relocatable Object Code

Explanation:
Three-Address Code (TAC) is widely used as it simplifies optimization and translation to machine code.

Answer: B) Three-Address Code (TAC)


5. Which of the following is an advantage of using an intermediate representation?

A) Increases compilation time
B) Reduces portability
C) Allows for code optimization before machine code generation
D) Makes debugging difficult

Explanation:
An intermediate representation allows optimization and improves portability across different architectures.

Answer: C) Allows for code optimization before machine code generation


6. Which of the following statements about Three-Address Code (TAC) is TRUE?

A) Each instruction has only one operand
B) It is directly executed by the CPU
C) It breaks down complex expressions into simple statements with at most three operands
D) It cannot be used for optimization

Explanation:
TAC simplifies expressions into basic operations with at most three operands, making it suitable for optimization.

Answer: C) It breaks down complex expressions into simple statements with at most three operands


7. Which of the following is an example of a Three-Address Code (TAC) instruction?

A) A = B + C * D
B) t1 = C * D; t2 = B + t1; A = t2;
C) MOV A, B
D) PUSH AX

Explanation:
TAC breaks complex expressions into simpler steps with temporary variables, as shown in option B.

Answer: B) t1 = C * D; t2 = B + t1; A = t2;


8. What is the main purpose of using Static Single Assignment (SSA) form in intermediate code?

A) Reduce the number of instructions
B) Improve readability of the source code
C) Ensure that each variable is assigned only once
D) Generate direct machine code

Explanation:
In SSA form, every variable is assigned exactly once, which helps in optimization and register allocation.

Answer: C) Ensure that each variable is assigned only once


9. Which of the following intermediate code representations is based on a stack machine model?

A) Three-Address Code
B) Postfix Notation
C) Abstract Syntax Tree
D) Control Flow Graph

Explanation:
Postfix notation (Reverse Polish Notation) follows a stack-based evaluation model.

Answer: B) Postfix Notation


10. In the context of intermediate code generation, what is a basic block?

A) A single line of assembly code
B) A set of statements with only one entry and one exit point
C) A recursive function
D) A high-level function definition

Explanation:
A basic block is a sequence of statements where execution always enters at the beginning and exits at the end without jumps or branches in between.

Answer: B) A set of statements with only one entry and one exit point

Comments

Popular posts from this blog

Top 5 Safe Chat Apps for Kids with Parental Controls

Now a days kids are growing up with technology at their fingertips. While communication apps help children stay connected with family and friends, safety remains a top concern for parents. Unregulated platforms can expose children to inappropriate content, online predators, and cyberbullying. That’s why choosing a kid-friendly chat app with parental controls is essential. To help parents find the best options, we’ve compiled a list of the top five safest chat apps for kids that offer safe and controlled environment. 1. Messenger Kids (By Meta) Best for: Safe video calls and text messaging with parental supervision Features: Parents approve all contacts No ads or in-app purchases Fun filters, stickers, and games Monitored messaging and activity reports Why It’s Safe: Messenger Kids is designed for children under 13 and requires parental approval for every contact. Parents can monitor chats and control screen time through the Parent Dashboard. Download Messenger Kids 2...

10 Distance Vector and Link-State Routing MCQ

  10 multiple-choice questions  on  Distance Vector and Link-State Routing with explanations, useful for  UGC NET, SET, GATE, ISRO, and other competitive exams . Question 1: Basic Concept of Distance Vector Routing Q1: In a distance vector routing protocol, how do routers share routing information? A) By flooding the entire network with routing updates B) By periodically exchanging routing tables with their immediate neighbors C) By using a link-state database to determine the shortest path D) By dynamically updating paths based on link failure reports Answer: B) By periodically exchanging routing tables with their immediate neighbors Explanation: In Distance Vector Routing, routers share their routing tables with neighbors at regular intervals, leading to a simple but slow convergence mechanism. Question 2: Example of Distance Vector Routing Protocol Q2: Which of the following is an example of a Distance Vector routing protocol? A) OSPF ...

AI from Class 3: India’s Big Leap into the Future of Learning

Imagine that, it's a morning in 2026. In a classroom, a teacher holds up a tablet. Instead of reciting multiplication tables, a group of eight-year-olds watches a tiny animation explaining how computers “learn” from patterns. A curious hand shoots up. “Ma’am, does that mean my phone is smarter than me?” The class bursts into laughter, but the question lingers. That, in essence, is the beginning of India’s new chapter — where Artificial Intelligence is no longer a distant, sci-fi term, but a part of early education. The Turning Point The Central Board of Secondary Education (CBSE) has drafted a plan to introduce AI as a subject from Class 3 to Class 12 , a first in the country’s education history. The proposal, now with NCERT for expert review, aims to roll out by April 2026 . If all goes to plan, teacher training will begin next year, resource books and digital tools will follow, and by the time the next generation steps into school, “AI” will sit alongside English, Science,...