September 2001
Beginner
970 pages
23h 20m
English
Some of the while loop examples have been indefinite loops. That means, you don't know in advance how many times the loop will be executed before the expression becomes false. For example, when Listing 6.1 used an interactive loop to sum integers, you didn't know beforehand how many integers would be entered. Other examples, however, have been counting loops. They execute a predetermined number of repetitions. Listing 6.10 is a short example of a while counting loop.
// sweetie1.c -- a counting loop #include <stdio.h> int main(void) { const int NUMBER = 22; int count = 1; // initialization while (count <= NUMBER) // test { printf("Be my Valentine!\n"); // action count++; ... |
Read now
Unlock full access