Programming fundamentals - OCRInfinite loops

Programs are designed using common building blocks, known as programming constructs. These programming constructs form the basis for all programs.

Part ofComputer ScienceComputational thinking, algorithms and programming

Infinite loops

Condition-controlled loops can be written to continue forever. This is known as an . This program would run infinitely:

count = 10
repeat print(“Coding is cool”) count = count + 1
until count = 10

At the end of the , the value of the count will be 11. Because with each iteration the value of count increases by one, count will never have the value ten, so the loop will run infinitely.

Infinite loops can be created using either while or repeat loops.