Grade 11 · Practical
Procedures and functions
Structured Programming · about 4 min
Procedures and functions break a program into named, reusable blocks — the essence of modular, maintainable code.
Key points- A procedure performs a task; a function performs a task AND returns a value (via `Result`).
- Parameters pass data in: `procedure Greet(name : string);`. Value parameters copy; `var` parameters can change the caller's variable.
- Call a function inside an expression: `total := Add(a, b);`. Call a procedure as a statement.
- Modularity means each method is short, single-purpose, testable and reusable.
- Procedure — a named block that performs a task (no return value).
- Function — a named block that returns a value via Result.
- Parameter — data passed into a method.
EXAM TIP
if the question needs an answer back (a total, a boolean), write a FUNCTION and assign to Result; if it just does something, write a PROCEDURE.