September 2001
Beginner
970 pages
23h 20m
English
The main topic of this chapter has been program control. C offers you many aids for structuring your programs. The while and the for statements provide entry-condition loops. The for statements are particularly suited for loops that involve initialization and updating. The comma operator enables you to initialize and update more than one variable in a for loop. For the less common occasion when an exit-condition loop is needed, C has the do while statement.
A typical while loop design looks like this:
get first value
while (value meets test)
{
process the value
get next value
}
A for loop doing the same thing would look like this:
for (get first value; value meets test; get next value)
process the value
All these loops use a test ...
Read now
Unlock full access