Loops

Most computer programs have sections of code that need to be executed hundreds or even thousands of times during their life cycles. By using a looping construct it is possible to efficiently execute a series of instructions that work on large quantities of data. A simplified example might be that of an animation whose code might roughly translate to 'Start at the first frame of the animation; paint the window; move to the next frame; and repeat'. Fortunately, programming languages offer constructs to loop automatically through blocks of code based on a series of conditions. The first looping statement we'll examine is the While loop.