ABSTRACT

This chapter looks about the important principle of repetition. Repetition is one of the most powerful features of any computer programming language. It is created by looping with the while statement. The chapter explains about the need to avoid infinite loops. It suggests that the while statement can be used to create an indefinite loop that repeats a different number of times each time the program is run. The while statement can also be used to create a definite loop—also known as a counting loop—which repeats a specific number of times each time the program is run. The chapter also describes about the logical NOT operator (!) and how this operator can be used to create while loops using stop conditions. Processing provides support for another loop structure that is similar to the while loop: the do-while statement.