GCSE · Computer Science · AQA · Spec 8525
Logic errors
Picture a sat nav giving clear, confident directions all the way to the wrong town. No beep, no warning light. That's a logic error.
Computer Science · Algorithms
Trace table — dry run the code
This program should add up 1 + 2 + 3 + 4 + 5 and output 15. Be the computer: step through it line by line and see what it really does.
Ready when you are — step through one line at a time.
Now break the rules instead
Same program, different kind of mistake.
Take the same loop program, but this time line 3 has been typed as WHILE (count < 5 with the closing bracket missing. What happens when you try to run it?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
The program runs. No error message. And the answer is still wrong.
What you need to know
- Errors in programs come in different types. Syntax errors and logic errors are two of them.
- A syntax error breaks the rules of the language, so the code can't be translated and run until it's fixed.
- A logic error is valid code that runs but does the wrong thing, such as giving the wrong output.
- Logic errors are found by comparing what the program actually does with the result you expected.
The big picture
Programs can go wrong in different ways. A syntax error breaks the rules of the programming language, so the translator can't translate the code and reports the problem instead. A logic error is sneakier: every line is valid, the program runs, and it quietly produces the wrong result. You catch it by knowing what the result should be and checking.
Key points
Worked example
Problem
A program should output "Pass" for any score of 50 or more. It contains the line IF score > 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail". Is there an error? If so, what type?
⚠ Watch out
Thinking a program must be correct because it ran without an error message. That only tells you there are no syntax errors. It tells you nothing about logic errors.
Memory hook
Syntax is the grammar of code: break it and the translator complains straight away. Logic is the meaning: get it wrong and the program says nothing, it just gets the answer wrong.
Check yourself
A program should output "Too cold" for temperatures below 5. You enter 2: no output, no error message. Syntax error or logic error, and what's your evidence?
Flashcards
(6)What is a logic error?
What is a syntax error?
A program runs with no error message. What does that prove?
Why can't the translator detect a logic error?
How do you find a logic error?
What is a dry run?
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.