CompTIA ITF+ (FC0-U61) — Question 105

Which of the following should a developer use to ensure a block of code executes a defined number of times?

Answer options

Correct answer: A

Explanation

The correct answer is A, the for loop, which is specifically designed to execute a block of code a predetermined number of times. While a while loop (option B) can also repeat code, it does not inherently limit the number of iterations, and if ... else statements (option C) and switch statements (option D) are used for conditional execution rather than repeated execution.