๐Ÿ“˜

Function

A named, reusable set of instructions.

๐Ÿ˜Š In simple words

A named, reusable set of instructions.

๐ŸŽ“ Technical definition

A self-contained block of code that takes parameters, performs a task and can return a value; it runs only when called.

Pseudocode example
1FUNCTION SQUARE(N)2    RETURN N * N3END FUNCTION4DISPLAY SQUARE(4)

๐ŸŽ Real-world analogy

A blender: put things in, press a button, get a smoothie out.

๐Ÿ”— Related concepts

โ† Whole glossary