Translating Expressions and Control Flow Statements MCQs January 8, 2026December 14, 2024 by u930973931_answers 15 min Score: 0 Attempted: 0/15 Subscribe 1. What is the primary goal of translating expressions in a compiler? (A) To optimize the expressions (B) To simplify the expressions and evaluate them efficiently (C) To directly map high-level code to machine code (D) To check for syntax errors in the expressions 2. Which of the following is commonly used to translate arithmetic expressions in a compiler? (A) Regular expressions (B) Directed Acyclic Graph (DAG) (C) Control flow graph (D) Abstract syntax tree (AST) 3. In the context of translating control flow statements, what does a “branch” refer to? (A) A variable declaration (B) A loop in the code (C) A point where the program execution can diverge based on a condition (D) A mathematical operation 4. Which of the following is the primary function of a control flow statement in a program? (A) To define the variables used in the program (B) To manage the sequence of operations based on conditions (C) To allocate memory dynamically (D) To handle exceptions during runtime 5. Which of the following best describes a basic block in control flow analysis? (A) A group of variables used in a function (B) A sequence of instructions that always results in a loop (C) A sequence of instructions with no branches, except at the end (D) A specific type of data structure 6. What is the typical outcome of translating a conditional jump (like an if statement) in a compiler? (A) The execution skips the entire program (B) It creates a branch in the control flow graph (C) It eliminates the need for further optimization (D) It directly generates machine code for conditional checks 7. Which of the following expressions is typically translated into a temporary variable in Three-Address Code (TAC)? (A) while x < 20 do (B) x = 5 (C) if x > 10 then (D) result = a + b * c 8. What is the role of a “goto” statement in control flow translation? (A) It creates a loop in the program execution (B) It creates a new function (C) It specifies the target address for branching to another part of the program (D) It allocates memory for variables 9. Which of the following control flow structures is typically represented by a directed edge in a control flow graph (CFG)? (A) Variables (B) Loops (C) Branches or jumps (D) Function calls 10. What is a “return” statement in control flow translation commonly translated to in machine code? (A) A jump to the end of the program (B) A jump to the next instruction in the program (C) A loop that repeats the execution of the current function (D) A branch that exits the function and returns control to the calling function 11. How does a “while” loop typically get translated in a compiler? (A) By translating it into a sequence of basic blocks and conditional jumps (B) By translating it into a simple expression (C) By creating an infinite loop in the program (D) By removing the loop entirely 12. Which of the following is a key step in translating control flow statements in a compiler? (A) Mapping control flow structures to basic blocks (B) Checking for syntax errors only (C) Generating the final machine code directly (D) Analyzing the scope of variables 13. In a program’s control flow graph (CFG), what does a “node” represent? (A) A specific operation in the program (B) A variable used in the program (C) A basic block in the program (D) A syntax error in the program 14. Which intermediate representation is typically used to translate conditional expressions? (A) Abstract syntax tree (AST) (B) Control Flow Graph (CFG) (C) Three-Address Code (TAC) (D) Directed Acyclic Graph (DAG) 15. Which of the following is a typical result of translating a for-loop in a compiler? (A) It generates a single statement with no branches (B) It is converted into a function call (C) It is converted into a combination of a conditional check and a jump (D) It is ignored by the compiler