GCSE · Computer Science · AQA · Spec 8525
Identifying and categorising errors
The scariest bug isn't the one that stops your program. It's the one that lets it run, look completely fine, and quietly hand you the wrong answer.
Computer Science · Categorising errors
Two questions sort any error
Pick an error in your head (a missing bracket, say, or < typed where <= was meant) and 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. The code has to be translated before the program can run at all.
3 possible routes.
The questions come in this order for a reason: until the code translates, there's 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 a murmur. Step through and catch the moment 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
- Every program error goes into a category, based on what causes it and how it shows up.
- There are two main categories to know: syntax errors and logic errors.
- A syntax error breaks the grammar rules of the programming language you're writing in.
- Typical culprits: a misspelt keyword, a missing bracket or colon, or a string that never gets its closing quote.
Have a goYour friend types OUTPT "Hello" instead of OUTPUT "Hello", and insists the computer is "just being fussy". Which category of error is it?
A syntax error.
OUTPT isn't a keyword in the language, so a grammar rule is broken. It isn't a logic error, because the thinking behind the line was fine; only the spelling broke the rules.
- Code with a syntax error can't be translated, so the program won't run. The translator usually reports the error and its line.
- A logic error is a mistake in the design or reasoning: < instead of <=, the wrong variable, or steps in the wrong order.
- With a logic error the program runs but gives an incorrect or unexpected result, and the translator reports nothing.
Have a goA program should output the area of a rectangle, but its line says area ← length + width instead of length × width. Will the translator complain?
No. It's a logic error, so nothing is reported.
length + width is perfectly legal code. The mistake is the wrong operator, a slip in the reasoning, so the program runs happily and gives the wrong area.
- Logic errors are found by testing: use test data whose expected output you know, then compare actual with expected.
Have a goSame buggy area program (it adds instead of multiplying). You test it with length 3 and width 5. What's the expected output, and what will it actually output?
Expected 15; actual 8.
Work out the expected answer by hand first: 3 × 5 = 15. The buggy line does 3 + 5 = 8. Without knowing the 15, you'd have no way to tell the 8 is wrong.
- If they don't match, trace the code, for example with a trace table, to find where the values go wrong.
- The fix: correct the rule-breaking code for a syntax error, or change the faulty logic so the program gives the intended result.
The big picture
Program errors come in two main categories, and you sort them by how they show up. Break the language's rules and the translator refuses the code: that's a syntax error, and you fix the rule-breaking code. Get the rules right but the thinking wrong, and the program runs but gives the wrong result: that's a logic error. The translator says nothing about it, so you find it by testing against an 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. An IF line is missing the colon its language needs: which category, and what does the translator do? Colon fixed, but it tests the wrong variable: which category now, and how would you find it?
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?
A test gives the wrong result. How do you pin down where the logic error is?
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
- Convert character to character code
- Correcting errors
- Data validation routines
- Equal to (relational operator)
- Greater than (relational operator)
- Greater than or equal to (relational operator)
- Indefinite (condition-controlled) iteration
- Integer / real to string conversion
- Integer data type
- Integer division and remainder
- Iteration
- Keyboard input
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 26 October 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.