Question Detail

COS 102 6 lecture note; fundamentals of programming Objective Question

Question

What is the primary purpose of an iteration statement (or loop) in programming?
Options
A To define custom functions that can be called multiple times.
B To execute a block of code repeatedly until a certain condition is met or fulfilled.
Correct Answer
C To choose between different blocks of code based on a condition.
D To handle errors and exceptions that occur during program execution.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 58 clearly states: "Loops can execute a block of code number of times until a certain condition is met." and "The iteration statement allows instructions to be executed until a certain condition is to be fulfilled."

Hint

Think about scenarios where you need to perform the same action multiple times, perhaps on different data items, until a specific goal is achieved.

Question Info