Essay on The Infinite Loop

Submitted By Martin1120
Words: 325
Pages: 2

The Infinite Loop A loop with no exit point is called an infinite loop because it never ends. The loop continues forever because the condition is that brings it to an end is true forever. The only slightly odd thing about the infinite loop is the way that you can leave out the first and final expressions. You can even leave out the middle expression and the result is an infinite loop even if it does look a little odd. Infinite loops are often the result of a programming error. You simply write a loop that never ends because of a mistake that you made in the exit condition. Generally the first you know of an infinite loop is that either the program goes into overdrive never stopping but producing some output or other but most often it simply all goes quiet while the loop just keeps looping. In many languages you can stop or break into a program that is stuck in an infinite. In all cases an infinite loop isn't really infinite - it has a time limit applied to it which automatically halts it. There is no easy way to abort a program before the time limit even using debugging environments. Break Command The break command allows you to create an exit point in a loop anywhere you care to place one - i.e. not just at the start or the end. While the loop initially looks like an infinite loop the “if” statement and the break bring it to a conclusion. When the condition is true the “if” statement executes the break which transfers control to the instruction following