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.
The questions come in this order for a reason: until the code translates, there is no program to test.
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.
Ready when you are — step through one line at a time.
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
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?
What is a syntax error?
What happens when code contains a syntax error?
Give three examples of a syntax error.
What is a logic error?
Give three examples of a logic error.
Why doesn't the translator report a logic error?
How is a logic error found?
Once a test shows a wrong result, how do you locate the logic error?
How do you fix each kind of error?
A program runs with no error messages. What do you know for certain?
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 postedMore AQA GCSE Computer Science topics
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.