GCSE · Computer Science · AQA · Spec 8525

Identifying and categorising errors

The most dangerous bug isn't the one that stops your program. It's the one that lets it run, look fine, and quietly give the wrong answer.

Computer Science · Categorising errors

Two questions sort any error

Think of an error — a missing bracket, say, or < typed where <= was meant. Walk it down the tree. Each question sends it one way only.

Will it translate? → Does it give the right answer?

  • Start with the rules of the language. A translator checks every line against them before the program can run.

3 possible routes.

On An error in a program. 2 branches to choose from.

The questions come in this order for a reason: until the code translates, there is no program to test.

Build the grid

What each case actually looks like

Tick every property that is true for each case. Take your time with the program that has no errors — it's the one that catches people out.

Program with a syntax error
Program with a logic error
Program with no errors

Computer Science · Algorithms

Trace table — dry run the code

This program should add up every whole number from 1 to n. Our test: n = 4, so the expected output is 1 + 2 + 3 + 4 = 10. It translates and runs without complaint. Step through and find where it goes wrong.

1n ← USERINPUT
2total ← 0
3i ← 1
4WHILE i < n
5 total ← total + i
6 i ← i + 1
7ENDWHILE
8OUTPUT total
n
total
i
i < n
Output
Press Start to run the first line.
·

Ready when you are — step through one line at a time.

What do you think?

It runs — so is it finished?

Maya's program translates first time and runs without a single error message. She closes her laptop and says: "Done. It works."

Which is closest to what you think right now?
How sure are you?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Two questions sort any program error: will it translate, and does it give the right answer?

What you need to know

  • Errors in a program are put into categories by what causes them and how they show up. The two main categories are syntax errors and logic errors.
  • A syntax error breaks the grammar rules of the programming language, such as a misspelt keyword, a missing bracket or colon, or an unclosed string. The code can't be translated, so the program won't run, and the translator usually reports the error and its line.
  • A logic error is a mistake in the program's design or reasoning, such as the wrong operator, the wrong variable or steps in the wrong order. The program runs but gives an incorrect or unexpected result, and the translator does not report it.
  • Logic errors are found by testing: run the program with test data whose expected output is known, compare actual with expected, and trace the code (for example with a trace table) to locate where it goes wrong.

The big picture

Program errors fall into two main categories, and you sort them by how they show up. If the code breaks the language's rules, the translator refuses it: that's a syntax error, and you fix the rule-breaking code. If the program runs but gives the wrong result, that's a logic error. The translator never reports it, so you find it by testing against expected output and tracing, then change the faulty logic.

Key points

1Ask two questions in order: will the code translate, and does it give the right answer?
2Translator refuses it → syntax error → fix the rule-breaking code.
3Runs but wrong result → logic error → find it by testing and tracing, then change the faulty logic.
4A program that runs has no syntax errors. That says nothing about logic errors.

Worked example

Problem

A program should output the larger of two numbers, a and b. It contains the line IF a < b THEN OUTPUT a ELSE OUTPUT b. It is tested with a = 3 and b = 8. Categorise the error, and say how it would be found and fixed.

⚠ Watch out

Writing that a logic error means 'the program doesn't work'. That's too vague to show you understand it. Say what actually happens: the program runs, the output is wrong, and the translator reports nothing.

🧠

Memory hook

Syntax is the spelling and grammar of code; logic is the thinking behind it. The translator is a grammar checker, not a mind reader.

✓

Check yourself

Cover the page. A colon is missing from an IF line: which category, and what will the translator do? Now the colon's there but the IF tests the wrong variable: what changes?

Flashcards

(11)
What are the two main categories of program error?
Syntax errors and logic errors.
What is a syntax error?
A mistake that breaks the grammar rules of the programming language.
What happens when code contains a syntax error?
It can't be translated, so the program won't run. The translator usually reports the error and the line it's on.
Give three examples of a syntax error.
A misspelt keyword; a missing bracket or colon; an unclosed string.
What is a logic error?
A mistake in the program's design or reasoning. The program runs but produces an incorrect or unexpected result.
Give three examples of a logic error.
Using the wrong operator (such as < instead of <=); using the wrong variable; putting steps in the wrong order.
Why doesn't the translator report a logic error?
The code obeys all the language's rules, so there's nothing for the translator to flag. It checks rules, not meaning.
How is a logic error found?
By testing: run the program with test data whose expected output is known and compare the actual output with it.
Once a test shows a wrong result, how do you locate the logic error?
Trace the code, for example with a trace table, following the values line by line until they stop matching what should happen.
How do you fix each kind of error?
Syntax error: correct the rule-breaking code. Logic error: change the faulty logic so the program produces the intended result.
A program runs with no error messages. What do you know for certain?
It has no syntax errors. It could still contain a logic error.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 30 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.