Skip to study material
← Question index

QUESTION 14 · Logic building

What is pseudocode? Explain its conventions with an example.

5 marks

Answer in brief

Pseudocode is a way of writing an algorithm using simple words and structured statements, without following all the syntax rules of a programming language.

Common statements

  1. READ: Accept an input value. Example: READ number.
  2. Assignment: Store a value. Example: total ← 0. The arrow means assignment in this notation.
  3. IF and ELSE: Choose between actions based on a condition.
  4. WHILE or REPEAT: Carry out a group of steps repeatedly.
  5. OUTPUT: Display the required result.

Example: larger of two numbers

READ a, b
IF a >= b THEN
    larger ← a
ELSE
    larger ← b
END IF
OUTPUT larger

For a = 8 and b = 5, the condition is true and larger becomes 8. If both inputs are 8, choosing either one gives the correct largest value.

Advantages of pseudocode

  1. Easy to read: The writer can focus on the solution instead of semicolons and header files.
  2. Easy to change: Steps can be added or corrected before coding.
  3. Useful for coding: The structured steps can later be converted into C statements.

Writing rules

Write one clear action at a time. Indent statements that belong to a condition or loop. State how a loop ends and whether a boundary is included. Use the same notation throughout. Pseudocode has no single compulsory syntax, but another reader must be able to follow it. It is not a C program and cannot normally be compiled as C without conversion.

Key points

  • Pseudocode communicates logic rather than compilable syntax.
  • Indentation and explicit end markers clarify structure.