Courseiva
easyMultiple ChoiceObjective-mapped

FC0-U71 Practice Question: A junior developer is creating a script to…

A junior developer is creating a script to generate reports for each of 10 departments. The script should run the report generation code exactly 10 times. Which control structure should be used?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

for loop

A for loop is the best choice for iterating a fixed number of times. A while loop could work but is less clear for definite iteration. if-else and switch are conditional structures, not iterative.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • for loop

    Why this is correct

    A for loop is designed for definite iteration over a range or collection.

  • while loop

    Why it's wrong here

    A `while` loop repeats as long as its condition remains true, but it does not inherently enforce a fixed count of 10 iterations; the developer must manually initialise and increment a counter, risking infinite loops if the increment is omitted or the condition is miswritten. It is tempting because `while` loops are commonly used for indefinite iteration, such as polling a database until a record appears, where the exact number of repetitions is unknown in advance.

  • if-else

    Why it's wrong here

    if-else is used for conditional execution, not repetition.

  • switch

    Why it's wrong here

    switch is used for multi-way branching, not looping.

About these practice questions

This FC0-U71 question is part of Courseiva's 988-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This FC0-U71 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the FC0-U71 exam.