1

mrahmedcomputing

KS3, GCSE, A-Level Computing Resources

Lesson 2. Errors and Testing


Lesson Objective

  1. Be able to identify errors in code.
  2. Specifically Syntax, Logic and Runtime Errors.

Lesson Notes

Errors?

Errors can occur in many algorithms and programs. They can be referred to as bugs. The 3 types of errors you need to be aware of are: Syntax errors, logical errors and runtime errors.

  1. Syntax Errors: These are grammatical mistakes in the programming language itself, like typos or missing punctuation. They prevent your program from even starting and are usually easy to spot.
  2. Logical Errors: These occur when your code compiles and runs but produces incorrect results due to flaws in the internal logic. Think of them as following a flawed recipe - the steps are right, but the outcome is wrong. Debugging these can be more challenging.
  3. Runtime Errors: These errors happen during execution, often due to unexpected conditions like accessing invalid memory or dividing by zero. Imagine a recipe calling for an undefined ingredient or cooking at an impossible temperature - your program crashes unexpectedly.

Knowing these error types and their characteristics will help you identify and fix them more efficiently, leading to smoother development and more reliable code.


3