AQA · GCSE · Computer Science

    Course version: 8525 · Version from Sept 2020

    Robust and secure programming: logic error.

    A logic error is a fault in the reasoning of an algorithm or program: the code runs without crashing and the syntax is valid, but the result is wrong because the steps or conditions are wrong.

    Checked against the AQA 8525 specification (opens in a new tab) on .

    • Point 13 of 14

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    A logic error is a fault in the reasoning of an algorithm or program: the code runs without crashing and the syntax is valid, but the result is wrong because the steps or conditions are wrong. For example, a loop that should add the numbers 1 to 10 might use a condition that stops one iteration early, giving 45 instead of 55; or a comparison might use the wrong relational operator so a discount is applied when the total is below the threshold. Logic errors are not detected by the translator, so they must be found by tracing the algorithm with test data, comparing expected and actual outputs, and checking each condition and calculation against the intended design.

    What earns the marks

    • Defines a logic error as a fault in the reasoning or design of the algorithm or program, not a syntax or runtime fault.
    • States that the program still runs and produces output, but the output or behaviour is incorrect.
    • Gives a concrete example, such as a loop stopping one iteration early or a condition using the wrong relational operator.
    • Explains that a translator does not flag logic errors, so they are found by tracing with test data and comparing expected with actual results.

    Common mistakes and how to put them right

    • Confusing a logic error with a syntax error.

      Put it right: A syntax error breaks the rules of the language and stops translation, whereas a logic error allows the program to run but gives wrong results.

    • Assuming a program that runs without crashing is correct.

      Put it right: Running successfully does not mean the logic is right, so outputs must be checked against expected values.

    • Thinking a translator will report logic errors.

      Put it right: Translators detect syntax errors, so logic errors must be found by testing and tracing.

    Exam tips

    • Read the scenario and ask what the code is meant to do, then compare that with what it actually does.
    • Use a small trace table with sample inputs to show where the wrong value first appears.
    • Name the specific faulty condition or calculation rather than saying only that the program is wrong.

    Try the lesson

    The start of the Robust and secure programming: logic error. lesson, made from checked teaching notes for this specification point.

    Have a go first

    A program is meant to calculate the area of a rectangle as length × width, but the programmer writes area = length + width. The program runs without crashing. What type of error is this?

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Robust and secure programming: logic error.

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge