ZIMSEC O Level · Computer Science · Form 2, Form 3, Form 4
An algorithm is a set of step-by-step instructions to solve a problem.
Flowchart symbols
Oval (start/stop), parallelogram (input/output), rectangle (process), diamond (decision), arrows (flow).
Basic constructs
- Sequence: steps in order.
- Selection: IF … THEN … ELSE … ENDIF.
- Iteration (loops): FOR … NEXT (fixed number of times), WHILE … ENDWHILE (pre-condition), REPEAT … UNTIL (post-condition).
Worked example: Pseudocode to find the average of 10 marks.
Total ← 0
FOR Count ← 1 TO 10
INPUT Mark
Total ← Total + Mark
NEXT Count
Average ← Total / 10
OUTPUT Average
Trace tables
A trace table records the value of each variable as an algorithm runs. Use it to find errors (debugging) and to predict output.
Validation and verification
- Validation checks data is sensible: range check (0–100), type check, length check, presence check, format check.
- Verification checks data is copied correctly: double entry, visual check.
Exam tip: Indent the inside of loops and IF statements – it makes pseudocode readable and earns marks.
Check yourself
- Which flowchart symbol is used for a decision?
- Write a pseudocode IF statement that outputs “Pass” if Mark ≥ 50, otherwise “Fail”.
- Name a validation check that makes sure a mark is between 0 and 100.
Show answers
- A diamond.
- IF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF
- A range check.
Questions about this topic (0)
No questions about this topic yet.
Sign in or create a free account to join in.