BETAThis platform is under active development; bugs, missing features, and risk of data loss are present. Thank you for your support!

Identifying Errors

Learn it by playing

Answer these questions to earn energy, then fish and explore. No account needed.

For teachers: ready-to-use lesson slides, revision notes, diagrams for Identifying Errors (Computer Science, CIE) — use them in your lesson, or run the topic as a live class game.

Notes

Types of Errors

  • Three main categories: **syntax errors**, **logic errors**, and **runtime errors**.
  • Syntax errors break grammatical rules of the programming language and **prevent the program from running**.
  • Logic errors cause the program to run but **produce incorrect output**.
  • Runtime errors **cause the program to crash** during execution.
  • Trace tables help identify all types of errors by simulating program execution.

Syntax Errors

  • Examples: missing brackets, misplaced semicolons, typos in variable names, incorrect operator use.
  • Example: `def generateusername(firstname, lastname)` missing colon (`:`) at end.
  • Example: `firstname = imput(...)` misspelling `input` as `imput`.
  • Example: `usdrname = ...` typo in variable name.
  • Example: `main` missing parentheses `()` to call the function.

Logic Errors

  • Program runs but gives wrong results due to flawed logic.
  • Examples: incorrect comparison operators (`<` instead of `≤`), using `AND` instead of `OR`, off-by-one loops, array index errors.
  • Example: `if length < 0 or width < 0:` should be `≤ 0` to reject zero as non-positive.
  • Logic errors are often found using **trace tables** and test data.

Runtime Errors

  • Errors that occur during program execution, causing a crash.
  • Examples: division by zero, array index out of bounds, file not found, type conversion failure.
  • Example: entering `"abc"` for a float input crashes without a loop to retry.
  • Fix: wrap input in a `while True` loop with try-except to handle invalid input gracefully.

Using Trace Tables

  • A trace table records the state of variables at each step of algorithm execution.
  • Helps detect logic errors by comparing expected vs actual outcomes.
  • Each column represents a variable; each row shows values after a line of code.
  • Useful for dry-running algorithms in exams.

Writing & Amending Algorithms

  • Algorithmic thinking uses **abstraction** and **decomposition** to break problems into steps.
  • Plan algorithm in parts: declare variables, input, process, loop, output.
  • Use variable names and data exactly as given in the question to avoid losing marks.
  • Comment code to explain logic and help examiners award marks.
  • Pseudocode has no strict syntax, but follow IGCSE specification for consistency.

Exam Tips

  • Describe syntax errors as 'prevents the program from running'.
  • Describe logic errors as 'produces incorrect output'.
  • Describe runtime errors as 'causes the program to crash'.
  • Name the error type, locate it, and explain its impact on output/execution.
  • Use scrap paper to draft algorithms before writing final answer.

Example series circuit for testing logic: if switch is open, bulb off; if closed, ammeter reads current.

Series circuit1.5 VLampA

Practice questions

Free preview — 8 of 40 questions. Sign up to see them all.

  1. 1.Which type of error prevents a program from running?

    Easy
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DOff-by-one error
  2. 2.Which type of error causes a program to crash while it is running?

    Easy
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DCompilation error
  3. 3.A program runs but produces an incorrect result. What type of error is most likely present?

    Medium
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DInput error
  4. 4.Which of the following is an example of a syntax error?

    Medium
    • AUsing a variable before it is assigned
    • BDividing by zero
    • CMissing a colon at the end of a function definition
    • DAn array index going out of bounds
  5. 5.In the following pseudocode, what type of error is present? FOR i ← 1 TO 10 OUTPUT i NEXT i (Assume the loop should output numbers 1 to 10, but it outputs 1 to 11.)

    Hard
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DNo error
  6. 6.Which of the following is NOT a common type of error in programming?

    Easy
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DDesign error
  7. 7.A programmer writes: IF age > 18 THEN OUTPUT 'Adult' ELSE OUTPUT 'Child'. The program always outputs 'Child' even when age is 20. What type of error is this?

    Medium
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DTypo error
  8. 8.A program crashes when the user enters a string instead of a number. This is an example of a:

    Hard
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DCompilation error

Unlock all 40 questions, slides & more

Create a free account to see every question, the slides, flashcards and revision notes for this topic.

Past papers

Past-paper practice for this topic is coming soon.

🗂️ Coming soon