ABSTRACT

Programs often contain blocks of code that must be executed more than once. A statement whose job is to repeatedly execute the same code as long as the value of a controlling expression is true creates an iteration loop. This chapter discusses the C's iteration statements: for, while, and do-while, which allow us to set up loops, as well as the break, continue, and goto statements, which can be used to transfer control from one point of a program to another. When an iteration loop is included in the body of another loop, each iteration of the outer loop triggers the execution of the nested loop. The chapter also discusses how a break statement terminates the execution of a switch statement. The continue statement can be used only inside a for, while, or do-while loop. While the break statement ends the loop, the continue statement terminates the current iteration of the enclosing loop and causes the next iteration to begin.