Skip to content

October 18, 2026

Algorithms, flowcharts and pseudocode

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

  1. Which flowchart symbol is used for a decision?
  2. Write a pseudocode IF statement that outputs “Pass” if Mark ≥ 50, otherwise “Fail”.
  3. Name a validation check that makes sure a mark is between 0 and 100.
Show answers
  1. A diamond.
  2. IF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF
  3. A range check.

Questions about this topic (0)

No questions about this topic yet.

Leave a Reply

Your email address will not be published. Required fields are marked *