We read your photo as:
Which loop is most compact for counter-controlled iteration.
Computer Science
ScanSolve AI Answer
Answer
C
The question asks which loop is most compact for counter-controlled iteration.
- A. Do-while: A
do-whileloop executes its body at least once, then checks the condition. For counter-controlled iteration, the counter initialization, condition, and increment/decrement are typically spread across multiple lines (before the loop, in thewhilecondition, and inside the loop body). - B. While: A
whileloop checks its condition before executing its body. Similar todo-while, for counter-controlled iteration, the counter initialization, condition, and increment/decrement are usually on separate lines. - C. For: A
forloop is specifically designed for counter-controlled iteration. It consolidates the initialization of the counter, the condition for continuation, and the update (increment/decrement) of the counter into a single, compact line in the loop header. This makes it the most concise and readable option for this purpose. - D. Switch: A
switchstatement is a selection control structure, not a loop. It is used to execute different blocks of code based on the value of a variable, not for repeated execution.
Therefore, the for loop is the most compact for counter-controlled iteration.
The correct option is C.
C) For
Was this helpful?
Try one yourself
A new problem that tests the same skill.
Still stuck on this one?
Ask a follow-up, and the answer starts from this question.
Got a different question?Ask your own question
More Computer Science Questions
QWhat is the purpose of a loop in programming?QWhat is the function of loops of helnQWhat are the key differences between a while loop and a for loop in programming?QExplain the execution flow and results of the provided algorithm, including identifying loop…QExplain selection and iteration control structures with examples.

Handwritten Step-by-Step Solution
Get this as a handwritten image on WhatsApp — like a tutor wrote it for you.
Try on WhatsApp