Repetition

A loop is a sequence of instructions that are repeated until a certain Boolean condition is true (or false). When looping, the program must have an instruction to allow the loop to stop. If the instruction is missing (or present but never triggered), the repetitions will go on forever. This is known as an infinite loop. If you accidentally create an infinite loop, you will have a logical error in your program. The program will compile but when you run it, it will most likely give you an overflow error or just hang. The condition that must be triggered can either be at the beginning or the end of the repetition structure. There are several repetition structures, just like there were several different selection structures, each for a different purpose.