What Does Iteration Mean?
Iteration, in the context of computer programming, is a process wherein a set of instructions or structures are repeated in a sequence a specified number of times or until a condition is met. When the first set of instructions is executed again, it is called an iteration. When a sequence of instructions is executed in a repeated manner, it is called a loop.
Techopedia Explains Iteration
Iteration is the repetition of a process in a computer program, usually done with the help of loops.
An example of an iteration programming language is as follows:
Consider a database table containing 1000 student records. Each record contains the following fields:
- First name
- Last name
- Roll no
If one wants to copy all the student records from the database and print them, the best way to retrieve the record is to iterate or loop through each record. It can be executed using the for loop statement as shown below:
for (int i=0;i<1000;i++)
{
Print first name and last name from table
}
In the above example, i is an iterator starting from the first student record to the last student record.