|
|
HP C/HP-UX Reference Manual: Version A.05.55.02 > Chapter 6 Statements while |
|
The while statement executes the statements within a loop as long as the specified condition, exp, is true. This is one of the three looping constructions available in C. Like the for loop, the while statement tests exp and if it is true (nonzero), statement is executed. Once exp becomes false (0), execution of the loop stops. Since exp could be false the first time it is tested, statement may not be performed even once. The following describes two ways to jump out of a while loop prematurely (that is, before exp becomes false): /* Program name is "while_example" */ If you execute this program, you get the following output: Enter a string Four score and seven years ago |
|