Iteration is a process in computer programming that repeats a function a set number of times, with the result of each iteration often feeding into the next. Iterative functions run the same code block repeatedly and automatically, processing multiple chunks of data in sequence without redundant code.

The most common forms of iteration used in computer programs are while loops and for loops. Loops run repeatedly as long as a specified condition is true. For example, a developer first creates a variable that tracks how many times the function has run, then sets a total number of loops. After each iteration finishes, it increments the tracking variable and runs again until the tracking variable reaches the total number previously set.

While the specific syntax of while and for loops varies in each programming language, they often follow a similar pattern. The syntax for these loops in Java looks like this:

While loop: while (i < 30) { ... i++; }

For loop: for (i=0; i < 30; i++) { ... }

Both samples first create a tracking variable, i, and a total number of times for the iteration to run. The while loop includes the incrementation command, i++, at the end of the function, then checks the condition again when it starts over. The for loop creates the tracking variable, the total number of iterations, and how to increment the tracking variable at the start.

An while loop repeats as long as its condition is true, and ends once its condition is false
An while loop repeats as long as its condition is true, and ends once its condition is false

Software developers use iterative loops for many common purposes. For example, a developer may use an iterative function to perform calculations on each value in an array, running once for each array address until it reaches the end. A web developer may use a PHP script with an iterative loop to pull lines from a database record, add HTML formatting to display that content in a table, then close the table after getting the final line in the database record.

Updated June 5, 2023 by Brian P.

quizTest Your Knowledge

Decryption is required to open which of the following files?

A JPEG image captured by a digital camera
A password-protected PDF file
A video encoded with the MPEG-2 codec
A standard gzip-compressed file
Correct! Incorrect!     View the Decryption definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Iteration on this page is an original definition written by the team. If you would like to reference this page or cite this definition, please use the green citation links above.

The goal of is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.