Infinite loop

A programming term

A 'loop' in a program is a section of code that jumps back to its beginning to execute the same set of instructions over and over again. Some condition is checked each time to see if it is time to break out of the loop.

An infinite loop is almost always a mistake in programming. Effectively it stops the computer doing anything else except running through the loop.

An example of an infinite loop is shown below

x = 1

do {
     print x
} while x = 1     

Notice the mistake? There is nothing increasing the value of x - it is stuck at 1 and so this loop would carry on forever.

A proper loop looks like this

x = 1

do {
  print x
  x = x + 1

} while x < 11

Now the loop will only iterate 10 times.

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: infinite loops


back to glossaryback to glossary