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
- READ: Accept an input value. Example: READ number.
- Assignment: Store a value. Example: total ← 0. The arrow means assignment in this notation.
- IF and ELSE: Choose between actions based on a condition.
- WHILE or REPEAT: Carry out a group of steps repeatedly.
- 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
- Easy to read: The writer can focus on the solution instead of semicolons and header files.
- Easy to change: Steps can be added or corrected before coding.
- 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.