Skip to content

October 18, 2026

Programming concepts

ZIMSEC O Level · Computer Science · Form 3, Form 4

Variables, constants and data types

  • A variable is a named memory location whose value can change; a constant stays the same.
  • Data types: integer (whole numbers), real/float (decimals), string (text), Boolean (TRUE/FALSE), character.

Operators

Arithmetic (+, −, *, /, MOD for remainder, DIV for whole-number division); comparison (=, <>, <, >, <=, >=); logical (AND, OR, NOT).

Arrays

An array stores many values of the same type under one name, accessed by an index, e.g. Marks[1] to Marks[30].

Procedures and functions

Subprograms that perform a task. A function returns a value. They avoid repeating code and make programs easier to test.

Languages and translators

  • High-level languages (Python, Java, Visual Basic) are close to English; low-level languages (assembly, machine code) are close to the hardware.
  • A compiler translates the whole program at once into machine code; an interpreter translates and runs one line at a time; an assembler translates assembly language.

Errors

Syntax errors (breaking language rules), logic errors (program runs but gives wrong results), runtime errors (e.g. dividing by zero).

Worked example: What is 17 MOD 5 and 17 DIV 5?

17 MOD 5 = 2 (the remainder); 17 DIV 5 = 3 (the whole number of times 5 fits)

Exam tip: Choose meaningful variable names (TotalMarks, not x) – examiners expect good practice.

Check yourself

  1. Which data type stores TRUE or FALSE?
  2. Give one difference between a compiler and an interpreter.
  3. What type of error is caused by writing “PRNT” instead of “PRINT”?
Show answers
  1. Boolean.
  2. A compiler translates the whole program at once; an interpreter translates one line at a time.
  3. A syntax error.

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 *