Iteration

Updated: 06/30/2020 by Computer Hope
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 referred to as 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

Related pages

Programming terms