# Iteration

An is a plan, a set of step-by-step designed to solve a problem. There are three basic building blocks (constructs) to use when designing algorithms:

Algorithms are used to help design that perform particular tasks.

## What is iteration?

An explanation of iteration, as used in algorithms and programming

Algorithms consist of steps that are carried out (performed) one after another. Sometimes an algorithm needs to repeat certain steps until told to stop or until a particular has been met.

Iteration is the process of repeating steps.

For example, a very simple algorithm for eating breakfast cereal might consist of these steps:

1. put cereal in bowl
3. spoon cereal and milk into mouth
4. repeat step 3 until all cereal and milk is eaten
5. rinse bowl and spoon

The algorithm will repeat steps 3 and 4 until all the cereal and milk has been eaten.

## Why is iteration important?

Iteration allows us to simplify our algorithm by stating that we will repeat certain steps until told otherwise.

This makes designing algorithms quicker and simpler because they don’t have to include lots of unnecessary steps.

## Iteration in programming

Once an algorithm has been designed and perfected, it must be translated – or – into code that a computer can read.

We create programs to algorithms. Algorithms consist of steps. Programs consist of statements. A statement is a single instruction - in other words, a single step.

Iteration is implemented in programming using FOR and WHILE statements.

In programming, iteration is often referred to as ‘looping’, because when a program iterates it ‘loops’ to an earlier step.