mediumMultiple Choice
FC0-U71 Practice Question: Given the following pseudocode that calculates…
Given the following pseudocode that calculates the average of a list of numbers, which error will occur?
SET total = 0 SET count = 0 FOR EACH number IN list total = total + number count = count + 1 ENDFOR SET average = total / count OUTPUT average
⚠ Common exam trap
The key distinction is that this code runs correctly for non-empty lists but fails at runtime when the list is empty. This tests the difference between syntax/logic errors and runtime errors that occur under specific conditions.
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
✓
Runtime error
The pseudocode computes an average by dividing `total` by `count`. If the list is empty, `count` remains 0, and division by zero is a runtime error. This error occurs during execution, not during compilation or syntax checking, and is not a logic error because the code is logically correct for non-empty lists.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Compile-time error
Why it's wrong here
Pseudocode is not compiled, and the algorithm contains no syntax violations, undeclared identifiers or type mismatches that a compiler would reject. Compile-time errors arise in languages like Java or C# when code breaches grammar or type rules, which is the scenario where this option would apply.
- ✗
Logic error
Why it's wrong here
The pseudocode is syntactically valid and executes without runtime failure, so no error is raised; division by zero only occurs when the list is empty, which the stem does not state. Logic errors describe flawed intent, such as summing the wrong variable, and would be the answer if the algorithm produced incorrect results.
- ✗
Syntax error
Why it's wrong here
The pseudocode is syntactically valid: keywords, assignment and division operators are all correctly formed, so no syntax error occurs. A syntax error would arise from malformed tokens or misplaced keywords, whereas this code fails at runtime when count is zero, causing division by zero.
- ✓
Runtime error
Why this is correct
Division by zero occurs when the list is empty: count stays at zero, so total/count fails during execution rather than at compile time. This makes it a runtime error, since the pseudocode is syntactically valid and the fault only manifests when the loop body never runs.
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.