ICDL Coding Principles study materials
ICDL Coding Principles study resources

ICDL Coding Principles (ICDL): Coding Concepts and Program Structure

ICDL Coding Principles · Work through your exam, one topic at a time.

All guide sections

Coding Concepts and Program Structure

Building blocks of a program

Every program is built from sequence (statements run in order), selection (if / else, case) and iteration (loops). These three structures are enough to express any algorithm, and questions often ask you to say which structure a given snippet uses. Subprograms - procedures and functions - let you name a block of code and call it repeatedly. A procedure performs an action; a function also returns a value.

Parameters, arguments and scope

A parameter is the named placeholder in the subprogram definition; an argument is the actual value supplied in the call. Know the difference, because it is a favourite trap. Scope describes where a name can be seen: a variable declared inside a subprogram is local and ceases to exist when the subprogram ends; a global variable is visible throughout. A local variable with the same name as a global one shadows it, so changing it inside the subprogram does not change the global.

Other structural ideas

Identifiers must follow language rules (no spaces, cannot start with a digit, cannot be a reserved keyword). Constants hold values that must not change. Libraries and modules are imported so you can reuse tested code. Comments explain intent and are ignored by the translator. Indentation matters in some languages and is good style in all of them.

Rule of thumb

If a subprogram needs to send a result back to the caller, make it a function and assign the returned value: total = addVat(price). Calling addVat(price) without assigning or using the result is almost always a bug.

Worked example

FUNCTION area(width, height) - width and height are parameters. area(3, 5) passes arguments 3 and 5, and the call evaluates to 15, which must be stored or printed to be useful.