Iteration

Updated: 02/04/2024 by Computer Hope
Circular arrows representing iteration.

With computing, iteration describes going through a set of operations that deal with computer code. For example, in a computer program, one form of iteration is a loop. A loop repeats code until a certain condition is met. Each time the computer runs through a loop, it's called an iteration.

Many computer programs and programming languages use iterations to perform specific tasks, solve problems, and present solutions.

Example of an iteration

Below is a Perl for loop that goes through each element of an array and prints them to the screen.

my @example = qw(one two three four);
for (@example) {
 print "$_\n";
}

In the above example, the @example array has four elements and would print the following output to the screen. Each time an element is printed to the screen it's an iteration of that loop.

one
two
three four

Cycle, Factorial, Loop, Procedural, Programming terms, Recursion, Repetition