Cambridge IGCSE Computer Science · 0478
Topic 7: Algorithm Design and Problem-Solving — Part 3
Errors & Flowchart Symbols
Types of programming errors
Programs can contain three main types of error. Each is detected at a different stage:
| Error type | Description | When detected | Example |
|---|---|---|---|
| Syntax error | Breaks the grammar rules of the programming language | At compile/translate time — program will not run | Typing PRNT instead of PRINT |
| Logic error | Code runs but produces the wrong output due to flawed logic | During testing — program runs but results are incorrect | Using > instead of >= in a boundary condition |
| Runtime error | Causes the program to crash while it is running | During execution — program starts but stops unexpectedly | Divide by zero or accessing invalid memory |
Flowchart symbols
Flowcharts use standard symbols to represent different parts of an algorithm. Learn the shape and purpose of each:
| Symbol | Shape | Purpose |
|---|---|---|
| Terminator | Oval | Start or end of the algorithm |
| Process | Rectangle | A calculation or instruction (e.g. assign a value, perform arithmetic) |
| Input / Output | Parallelogram | Data entering or leaving the system (e.g. INPUT, PRINT) |
| Decision | Diamond | A question with two paths — Yes/No or True/False |
| Subroutine | Rectangle with double border | A pre-written procedure or function that is called |
| Flow line | Arrow | Shows the direction of flow between symbols |
Exam Traps
- Do not confuse process (rectangle) with input/output (parallelogram) or decision (diamond) — exam questions often test symbol shapes.
Explaining, finding and amending algorithms
To explain the purpose of an algorithm, describe its inputs, processes, and outputs in plain language. For example: "This algorithm reads three numbers, counts how many are greater than 10, and outputs the count."
Exam pseudocode must use precise symbols — write > or <=, not English phrases like "is greater than". Use the assignment arrow ←, not "=" for storing values.
Finding logic errors: Trace the algorithm step by step or use a trace table. Common mistakes include wrong comparison operators, incorrect loop bounds, and forgetting to initialise counters.
Amending an algorithm — before (logic error):
Count ← 0
FOR i ← 1 TO 3
INPUT Number
IF Number > 10 THEN
Count ← Count + 1
ENDIF
NEXT i
OUTPUT Count
The loop runs for i ← 1 TO 2 in the faulty version below, so the third input is never processed:
// Faulty version — only reads two numbers FOR i ← 1 TO 2
After (corrected): change the upper bound to 3 so all three inputs are processed: FOR i ← 1 TO 3.
0/15