Instruction Cycle and Control Flow MCQs

By: Prof. Dr. Fazal Rehman | Last updated: September 20, 2024

What is the primary purpose of the instruction cycle? A) To execute a single instruction B) To fetch, decode, and execute instructions C) To manage memory allocation D) To handle I/O operations Answer: B Which of the following stages comes first in the instruction cycle? A) Execute B) Decode C) Fetch D) Store Answer: C What does the decode stage of the instruction cycle do? A) Retrieves the instruction from memory B) Decodes the instruction into executable commands C) Executes the decoded command D) Stores the result of the execution Answer: B In which stage of the instruction cycle is the Program Counter (PC) updated? A) Fetch B) Decode C) Execute D) Store Answer: A Which register typically holds the address of the next instruction to be executed? A) Accumulator B) Instruction Register C) Program Counter D) Stack Pointer Answer: C What does the execute stage of the instruction cycle involve? A) Fetching the instruction B) Decoding the instruction C) Performing the operation specified by the instruction D) Updating the Program Counter Answer: C Which of the following is not a part of the instruction cycle? A) Fetch B) Decode C) Store D) Interrupt Answer: D What happens during the ‘store’ phase of the instruction cycle? A) The instruction is retrieved from memory B) The result of the execution is saved to memory C) The instruction is decoded into commands D) The Program Counter is incremented Answer: B What is the primary function of the control unit in a CPU? A) Perform arithmetic operations B) Manage data storage C) Direct the operation of the processor D) Handle I/O operations Answer: C Which of the following control flow statements is used to execute a block of code repeatedly based on a condition? A) if-else B) switch C) for loop D) goto Answer: C In a switch statement, what determines which case block will be executed? A) The value of the switch expression B) The order of the case blocks C) The default case D) The number of case blocks Answer: A What is the purpose of the ‘break’ statement in a switch-case construct? A) To exit the switch block and continue with the next statement B) To repeat the current case block C) To skip the rest of the current case block D) To exit the entire program Answer: A Which statement is used to terminate the execution of a loop prematurely? A) continue B) exit C) break D) return Answer: C What is the primary function of a ‘goto’ statement? A) To repeat a block of code B) To jump to a specific part of the code C) To conditionally execute code D) To handle exceptions Answer: B Which control flow statement is used to execute a block of code if a condition is true and another block if it is false? A) for B) while C) if-else D) switch Answer: C What happens if a ‘continue’ statement is encountered in a loop? A) The loop terminates immediately B) The current iteration of the loop is skipped and the next iteration begins C) The entire program terminates D) The loop condition is re-evaluated Answer: B What does a ‘return’ statement do in a function? A) Exits the function and optionally returns a value B) Continues execution of the function C) Terminates the entire program D) Jumps to a specific line of code Answer: A Which statement is used to handle multiple conditions in a branching statement? A) if-else B) for C) while D) switch Answer: D What is the purpose of the ‘default’ case in a switch statement? A) To handle an undefined case B) To repeat the current case C) To exit the switch block D) To skip the current case Answer: A What is the function of a loop’s condition? A) To determine the number of iterations B) To execute a block of code repeatedly C) To terminate the loop when false D) To initialize the loop variable Answer: C What will happen if the condition of a ‘while’ loop is never false? A) The loop will execute once B) The loop will execute indefinitely C) The loop will not execute D) The loop will throw an error Answer: B Which control flow statement can be used to execute a block of code based on the value of an integer variable? A) if B) while C) switch D) do-while Answer: C What does the ‘else if’ construct allow you to do? A) Handle multiple conditions in a single statement B) Skip execution of the entire ‘if-else’ block C) Repeat the ‘if’ condition D) Break out of a loop Answer: A How can you exit from a loop or switch statement? A) By using ‘continue’ B) By using ‘return’ C) By using ‘break’ D) By using ‘goto’ Answer: C What is a ‘for’ loop commonly used for? A) Handling exceptions B) Repeating a block of code a specified number of times C) Managing program flow D) Performing arithmetic operations Answer: B Which keyword is used to skip the remaining code in the current iteration of a loop? A) break B) continue C) return D) exit Answer: B Which control structure allows you to execute code based on a boolean condition? A) switch B) for C) if D) do-while Answer: C What does the ‘while’ loop do if its condition is initially false? A) Executes the loop body once B) Skips the loop body C) Executes the loop body indefinitely D) Causes a compile-time error Answer: B Which statement would you use to repeat a block of code until a condition becomes true? A) if B) for C) while D) switch Answer: C What is the function of the ‘goto’ statement in a loop? A) To skip the current iteration B) To exit the loop immediately C) To jump to a labeled statement D) To continue to the next iteration Answer: C What type of loop is guaranteed to execute at least once? A) for B) while C) do-while D) foreach Answer: C Which statement is used to execute code based on specific values of an expression? A) if-else B) while C) switch D) for Answer: C What is the use of the ‘break’ statement in a loop or switch statement? A) To skip the remaining iterations or cases B) To terminate the loop or switch block execution C) To re-evaluate the loop condition D) To initialize loop variables Answer: B In which type of loop is the loop condition tested before the loop body executes? A) do-while B) while C) foreach D) for Answer: B What control flow statement is used to repeat a block of code while a condition is true and execute at least once? A) for B) while C) do-while D) switch Answer: C Which statement will always be executed in a ‘do-while’ loop? A) The initialization statement B) The condition check C) The loop body D) The ‘break’ statement Answer: C What happens if you place a ‘return’ statement inside a loop? A) The loop continues executing B) The function exits immediately, terminating the loop C) The loop condition is re-evaluated D) The loop restarts from the beginning Answer: B Which statement is used to perform a conditional jump in a program? A) goto B) switch C) while D) break Answer: A Which type of loop checks its condition at the end of the loop body? A) while B) for C) do-while D) foreach Answer: C What happens when the ‘continue’ statement is executed in a loop? A) The loop terminates B) The current iteration is skipped, and the loop proceeds to the next iteration C) The loop condition is re-evaluated D) The loop restarts from the beginning Answer: B In a switch-case statement, which statement can be used to ensure that the execution of code continues through all subsequent cases? A) continue B) break C) default D) no statement required Answer: D Which loop construct is best suited for iterating through elements of an array or collection? A) for B) while C) do-while D) switch Answer: A What will happen if a loop’s exit condition is never met? A) The loop will execute once B) The loop will execute indefinitely C) The loop will not execute D) The loop will cause a compile-time error Answer: B Which control flow structure allows for multiple paths of execution based on different conditions? A) switch B) for C) while D) do-while Answer: A What is the purpose of the ‘default’ case in a switch statement? A) To handle unexpected values B) To repeat the current case C) To exit the switch block D) To skip the rest of the switch statement Answer: A What is the result of using a ‘goto’ statement in modern programming practice? A) Encourages clean and structured code B) Often leads to unmanageable code and is generally discouraged C) Enhances code readability D) Ensures that the code is executed in sequence Answer: B Which statement allows for a block of code to be executed as long as a condition remains true? A) switch B) for C) if D) do-while Answer: D In a nested loop, which statement affects the inner loop execution? A) break B) continue C) return D) goto Answer: B What is the role of the ‘return’ statement in a function with a non-void return type? A) To exit the function and provide a value to the caller B) To repeat the function execution C) To skip the function’s remaining code D) To jump to a specific line in the function Answer: A What type of loop would you use when the number of iterations is known beforehand? A) while B) for C) do-while D) foreach Answer: B What happens if an infinite loop is encountered in a program? A) The program terminates B) The program continues executing the loop indefinitely C) The loop executes once D) The loop condition is ignored Answer: B Which control flow construct is typically used for error handling in programming? A) if-else B) switch C) try-catch D) for Answer: C In a for loop, where is the loop variable typically initialized? A) Inside the loop body B) In the loop condition C) In the loop increment section D) In the loop initialization section Answer: D Which statement in a switch-case construct is used to handle all cases not explicitly listed? A) break B) default C) continue D) return Answer: B What is the result of a loop with an always-true condition? A) The loop will execute once B) The loop will execute indefinitely C) The loop will not execute D) The program will crash Answer: B Which control flow statement would you use to execute code a fixed number of times? A) if B) switch C) for D) while Answer: C What happens when ‘continue’ is used within a ‘for’ loop? A) The current iteration is skipped, and the next iteration begins B) The loop terminates immediately C) The loop condition is re-evaluated D) The entire program terminates Answer: A Which control structure is used to execute code when a specific condition is true and stop when it becomes false? A) while B) for C) do-while D) switch Answer: A What is the role of the ‘goto’ statement in a switch-case statement? A) To jump to a specific case B) To skip the switch-case block C) To exit the switch-case statement D) To continue with the next case Answer: A

Read More Computer Architecture MCQs

  1. SET 1: Computer Architecture MCQs
  2. SET 2: Computer Architecture MCQs
  3. SET 3: Computer Architecture MCQs
  4. SET 4: Computer Architecture MCQs
  5. SET 5: Computer Architecture MCQs
  6. SET 6: Computer Architecture MCQs
  7. SET 7: Computer Architecture MCQs
  8. SET 8: Computer Architecture MCQs
  9. SET 9: Computer Architecture MCQs
 
All Copyrights Reserved 2025 Reserved by T4Tutorials