Understanding What an Algorithm Is
Inputs, Outputs, and Instructions
Inputs, Outputs, and Instructions
An algorithm doesn't work in a vacuum: it needs starting data, called inputs, and it produces a result, called the output.
Let's go back to the tea recipe example: the input is the water and the tea bag; the output is the cup of tea ready to drink. In computer science, it's the same: an algorithm that calculates an average takes grades as input, and produces an average as output.
Here's a simple diagram to represent how this works:
(INPUT) -> (PROCESSING: the instructions) -> (OUTPUT)
An instruction is a basic action, such as:
- reading a value given by the user,
- performing a calculation (addition, comparison...),
- displaying a result on screen,
- storing a value to use later.
When several instructions follow one another, in a specific order, this is called a sequence of instructions. This is the simplest structure of an algorithm: you execute the first instruction, then the second, then the third, and so on until the end.
For example, an algorithm that calculates the perimeter of a rectangle could be:
1. (Read the length L)
2. (Read the width l)
3. (Calculate P = 2 x (L + l))
4. (Display P)
Here, steps 1 and 2 are inputs, step 3 is processing, and step 4 produces the output. Understanding this input/processing/output distinction will help you enormously when you start writing real programs, because that's exactly how you think before coding.

