The function of structural components of programs - EdexcelIteration

Programs are designed and implemented using common building blocks, known as programming constructs. These constructs are sequence, selection and iteration and they form the basis for all programs.

Part ofComputer ScienceApplication of computational thinking

Iteration

is the third programming construct. There are times when a needs to repeat certain steps until told otherwise, or until a condition has been met. This process is known as iteration.

Iteration is also often referred to as , since the program ‘loops’ back to an earlier line of code. Sections of code that are iterated are called loops.

Iteration enables programmers to greatly simplify a program. Instead of writing out the same lines of code again and again, a programmer can write a section of code once, and ask the program to it again and again until it is no longer needed.

An explanation of iteration, as used in algorithms and programming

This program prints a message out six times:

SEND ‘Coding is cool’ TO DISPLAY SEND ‘Coding is cool’ TO DISPLAY SEND ‘Coding is cool’ TO DISPLAY SEND ‘Coding is cool’ TO DISPLAY SEND ‘Coding is cool’ TO DISPLAY SEND ‘Coding is cool’ TO DISPLAY