Loops

If statements represent one method of controlling the flow of program execution. They are an example of what is called a control block. Loops, another type of flow control, offer a different way of controlling the execution of a program.

Very often you will want a program to perform a given set of instructions multiple times. This is exactly what a loop does. Loops generally execute a block of commands either a prescribed number of times, or execute the commands until some condition is met. We will look at three different types of loops: for loops, while loops and do..while loops.

next


 home                      table of contents                      about