Definition
Iteration is the act of executing a block of code repeatedly, each pass operating on a different element or with a different value of a controlling variable. It is one of the two fundamental forms of repetition in computing — the other being recursion — and the more common in imperative languages. Every for loop, while loop, do-while loop, foreach, map, filter, list comprehension, and generator is a different surface syntax over the same underlying idea: do this thing N times, or until a condition is met, or once for each item in a collection.
The reason iteration is so central is that almost every interesting computation involves working through a collection of inputs and combining or transforming them. Without iteration, programs could express only fixed-size computations whose every step had to be written out explicitly.
Why it matters
How it works
The classical for loop has three parts: initialise a counter, test whether to continue, advance the counter. Each pass through the loop body runs once between the test and the advance. While loops drop the counter machinery, keeping only the test — useful when the number of iterations is not known in advance (read lines until end-of-file, retry the network request until it succeeds). Foreach and iterator-based loops abstract away the counter entirely: ask the collection for its next element until it says there are no more. This abstraction lets the same loop syntax work over arrays, linked lists, trees, database query results, file lines, and infinite streams.
Underneath the syntax, iteration is implemented through state — a counter, a cursor, a position pointer — that the loop body advances on each pass. The state may live on the stack (a local index), in a heap object (an iterator with a next-method), or implicitly in the program counter for recursive iteration (where each recursive call is one pass and the function arguments encode the state). Functional languages prefer the implicit form via recursion and higher-order functions like map and fold; imperative languages prefer explicit counters and mutation. Both express the same family of computations — the choice is ergonomic, not theoretical.