mediumMultiple Choice
FC0-U71 Practice Question: A program needs to display a message based on a…
A program needs to display a message based on a user's age. If age is 18 or over, it displays 'Adult'; otherwise, it displays 'Minor'. Which control structure should be used?
⚠ Common exam trap
CompTIA often tests the distinction between selection (if-else) and iteration (loops), so the trap here is that candidates might confuse the 'condition' in a while loop with the conditional logic needed for a binary decision, leading them to incorrectly choose a loop structure.
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
✓
If-else statement
The if-else statement is the correct control structure because it evaluates a single condition (age >= 18) and executes one block of code if true ('Adult') and another block if false ('Minor'). This is the standard branching mechanism in most programming languages for binary decisions based on a comparison.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
If-else statement
Why this is correct
An if-else statement evaluates a Boolean condition and selects exactly one of two branches, matching the two mutually exclusive outcomes the stem requires: 'Adult' when age is 18 or over, 'Minor' otherwise. No repetition or multi-way branching is needed, so this structure satisfies the binary decision constraint directly.
- ✗
For loop
Why it's wrong here
A for loop repeats a block a set number of times, so it cannot branch on whether age meets the threshold. It is tempting because loops iterate over data, and it would be correct where the same message must be produced for every record in a collection.
- ✗
Switch-case statement
Why it's wrong here
A switch-case compares one expression against discrete constant values; an age threshold is a range comparison, so no case label matches 18-or-over. It is tempting because it selects among outcomes, and it would be correct for mapping distinct fixed values, such as category codes, to messages.
- ✗
While loop
Why it's wrong here
A while loop repeats while a condition remains true, which would either never execute or run indefinitely rather than select one of two messages. It is tempting because it tests a condition, and it would be correct where processing must continue until a state changes.
Go deeper
Related to this question
About these practice questions
One of 988 original FC0-U71 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.