A loop is a sequence of instructions that is repeated until a certain condition is met. An example would be the process of getting an item of data and changing it, and then making sure some condition is checked — such as if a counter has reached a prescribed number.

Loops are one way to execute a statement for a variable number of times. The same effect can be achieved with recursion, especially in languages where all data is immutable, making it impossible to update a counter variable.

See also