Courseiva
mediumMultiple Choice

Types of Programming Errors: Logic vs Runtime for CompTIA ITF+

A developer is debugging a script that calculates the average of a list of numbers. The output is always incorrect. Which type of error is most likely the cause?

Quick Answer

The answer is a logic error, because the script runs without crashing or failing to execute but consistently produces an incorrect output. This type of error stems from a flaw in the algorithm or the sequence of steps used to calculate the average, meaning the code is syntactically valid and runs to completion, yet the result is wrong due to a mistake in the underlying logic. On the CompTIA ITF+ FC0-U61 exam, questions about types of programming errors often test your ability to distinguish between syntax errors, which prevent code from running; runtime errors, which cause a crash during execution; and logic errors, which allow the program to run but yield incorrect results. A common trap is assuming any wrong output must be a runtime error, but remember that logic errors are silent—they don’t throw exceptions. For a quick memory tip, think: “Syntax stops, runtime crashes, logic lies.”

⚠ Common exam trap

The ITF+ exam often tests the distinction between syntax errors (which prevent execution) and logic errors (which allow execution but yield wrong results), so candidates may mistakenly choose syntax error when the script runs but outputs incorrect values.

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

✓

Logic error

A logic error occurs when the code runs without crashing but produces incorrect results due to a flaw in the algorithm or calculations. In this case, the script calculates the average incorrectly, such as dividing by the wrong count or summing incorrectly, which is a classic logic error.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Runtime error

    Why it's wrong here

    Runtime errors terminate execution with an exception, such as a division by zero, rather than producing a consistently wrong value. A script that completes and returns an incorrect average contains a logic error in its calculation. Runtime errors are tempting because they occur during execution, but they crash rather than silently miscalculate.

  • ✓

    Logic error

    Why this is correct

    A logic error means the code runs without crashing but the algorithm or formula is wrong, so the average is computed incorrectly every time. Syntax and runtime errors would halt or throw, whereas the stem describes consistently wrong output.

  • ✗

    Syntax error

    Why it's wrong here

    Syntax errors prevent the script from being parsed or executed at all, so no output would be produced. The script runs and returns an incorrect average, indicating flawed logic instead. Syntax errors are tempting because they are common coding mistakes, but they cause immediate failure rather than wrong results.

  • ✗

    Compile error

    Why it's wrong here

    A compile error halts execution entirely, so the script would never run or produce output at all. Since the script runs and returns a wrong average, the fault lies in the logic, not compilation. This option is tempting because compile errors are a familiar error class, but they cannot yield incorrect output from a running script.

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

Same concept, more angles

1 more way this is tested on FC0-U71

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. 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

medium
  • A.Compile-time error
  • B.Logic error
  • C.Syntax error
  • ✓ D.Runtime error

Why D: 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.

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.