← ACARA Digital Technologies Years 7–8

Logic error versus syntax error

A mistake in an algorithm's steps. It still runs to the end with no warning, but gives the wrong output. Only tracing or testing shows it, unlike a syntax error that breaks the writing rules.

Understanding Logic error versus syntax error in ACARA Digital Technologies Years 7–8

What it does: Every line is written correctly and the algorithm finishes, but the output is wrong, so it is a logic error. The flowchart can still be followed to the end, but students who pass get the wrong message. The steps are wrong, not the shapes. The wrong relational operator does not break any writing rules, so only testing a boundary value reveals the wrong output.

Common mistakes: This is a logic error. The total should start at 0. Starting at 10 means the program still runs to the end with no warning, but the output is always 10 too high. A trace table would show it. This is a logic error. Using > instead of >= means a 13 year old gets no output. The program runs with no warning but gives the wrong result. Testing with the value 13 reveals it.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 420–481) and word search (Modules 420–519).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
An algorithm runs to the end with no warning, but the output is wrong. What kind of error is this?
Logic errorSyntax error
Matches
IF age >= 13 THEN OUTPUT "Teen" ELSE OUTPUT "Child" (should be age >= 13 only for teen, but the test uses age > 13)
↓
This is a logic error. It runs with no warning, but a 13 year old gets the wrong output. Testing with age 13 shows it.
Applying
Meanings
Term
logic error
Meaning
A mistake in an algorithm's steps. It still runs to the end with no warning, but gives the wrong output. Only tracing or testing shows it, unlike a syntax error that breaks the writing rules.
Practice
INPUT mark1
Testing
Gaps
// Runs, wrong output: error
Check Answer
Spots
1total ← 0
2total ← 10

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Hyena' badge — Savannah Debugger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. An algorithm runs to the end with no warning, but the output is wrong. What kind of error is this?
A. Logic error ✓
B. Syntax error
A logic error lets the algorithm finish, but the steps give the wrong answer. A syntax error breaks the writing rules.
2. Which line has a logic error if it should work out the area of a rectangle? area ← width + height
A. It runs fine but adds when it should multiply, so the output is wrong ✓
B. It breaks the writing rules, so the algorithm cannot run
The line is written correctly, so it runs. But + gives the wrong output. Area needs width * height.
3. How can you find a logic error in an algorithm?
A. Wait for a warning message to tell you where it is
B. Trace it or test it and compare the actual output with the expected output ✓
A logic error gives no warning. Only tracing or testing shows that the output is wrong.
4. Which one is a syntax error?
A. OUTPUT total with a missing closing quote in OUTPUT "Total is ✓
B. total ← 0 at the start, then total ← total - score to add up scores
A missing quote breaks the writing rules. Subtracting instead of adding is a logic error because the steps are wrong but still run.
5. A flowchart for a pass mark check has the Yes and No arrows swapped. The flowchart can be followed from Start to End. What type of error is it?
A. Syntax error
B. Logic error ✓
The flowchart can still be followed to the end, but students who pass get the wrong message. The steps are wrong, not the shapes.

Match the Pairs

total ← 0 FOR each mark: total ← total + mark OUTPUT total / 3 (should divide by 4 marks) → A logic error: the algorithm runs to the end with no warning, but the average it outputs is wrong.
OUTPUT "Total is" total ) → A syntax error: the line breaks the writing rules because of the stray bracket, so it cannot be followed.
A logic error gives no warning. The algorithm finishes but the answer is wrong, like a loop that adds 1 when it should add 2. → count ← 0 REPEAT 5 TIMES count ← count + 1 OUTPUT count (should count by 2s)
A flowchart logic error: the decision arrows for Yes and No are swapped, so the chart works but gives the wrong result. → Decision: score >= 50? Yes → OUTPUT "Fail" No → OUTPUT "Pass"
IF age >= 13 THEN OUTPUT "Teen" ELSE OUTPUT "Child" (should be age >= 13 only for teen, but the test uses age > 13) → This is a logic error. It runs with no warning, but a 13 year old gets the wrong output. Testing with age 13 shows it.
IF score > 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF ) → This is a syntax error. The stray bracket breaks the writing rules, so the algorithm is not written correctly. It is not a logic error.

Key Term

logic error
A mistake in an algorithm's steps. It still runs to the end with no warning, but gives the wrong output. Only tracing or testing shows it, unlike a syntax error that breaks the writing rules.

Fill in the Blanks

1. area ← 4 + 3 OUTPUT area // Runs, wrong output: logic error
Hint: Type the kind of error that runs to the end with no warning but gives the wrong output.
2. OUTPUT "Hello // Missing quote breaks the writing rules // This is a syntax error
Hint: Type the kind of error that breaks the writing rules of the language.
3. // Using > here is a logic error at 13 IF age >= 13 THEN OUTPUT "Teen"
Hint: Type the relational operator that makes 13 count as a teen.
4. x ← 2 + 3 OUTPUT x // Only tracing or testing shows the bug
Hint: Type the activity, besides tracing, that reveals a logic error by checking outputs.
5. Decision: mark >= 50 ? No: OUTPUT "Fail" // Swapping Yes and No is a logic error
Hint: Type the branch label that should lead to the Fail output.

Spot the Error

Question 1
A total ← 0
B total ← 10
C total ← total + score
D OUTPUT total
Line B — This is a logic error. The total should start at 0. Starting at 10 means the program still runs to the end with no warning, but the output is always 10 too high. A trace table would show it.
Question 2
A INPUT age
B IF age >= 13 THEN
C IF age > 13 THEN
D ENDIF
Line C — This is a logic error. Using > instead of >= means a 13 year old gets no output. The program runs with no warning but gives the wrong result. Testing with the value 13 reveals it.
Question 3
A INPUT a
B INPUT b
C avg ← a + b / 2
D OUTPUT avg
Line C — This is a logic error. Without brackets, b is divided by 2 first and then added to a. The program runs without any warning but outputs the wrong average. It should be avg ← (a + b) / 2.
Question 4
A SET name TO "Sam"
B SET score TO 9
C OUTPUT name
D OUTPUT "Done
Line D — This is a syntax error. The closing quote is missing, so the line breaks the writing rules and the algorithm cannot run. A logic error would run to the end. It should be OUTPUT "Done".
Question 5
A total ← 0
B REPEAT 4 TIMES
C INPUT n
D total ← n
E END REPEAT
Line D — This is a logic error. The total is replaced each time instead of having n added to it. The loop still finishes with no warning, but the output is only the last number. Tracing total on each loop shows it.

Student with a class code? Join your class →