November 2001
Beginner
1128 pages
29h 12m
English
The while loop is a for loop stripped of the initialization and update parts; it has just a test condition and a body:
while (test-condition) body
First, a program evaluates the test-condition expression. If the expression evaluates to true, the program executes the statement(s) in the body. As with a for loop, the body consists of a single statement or a block defined by paired braces. After it finishes with the body, the program returns to the test-condition and reevaluates it. If the condition is nonzero, the program executes the body again. This cycle of testing and execution continues until the test-condition evaluates to false. (See Figure 5.3.) Clearly, if you want the loop to terminate eventually, something within the ...