Courseiva
mediumMultiple ChoiceObjective-mapped

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

    If-else evaluates a condition and executes one of two blocks.

  • For loop

    Why it's wrong here

    For loop is for repeating a block a fixed number of times, not for a simple condition.

  • Switch-case statement

    Why it's wrong here

    Switch-case is used when there are many discrete values, not a range condition like age >= 18.

  • While loop

    Why it's wrong here

    While loop repeats until a condition is false; it's not suitable for a single decision.

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 →

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.