December 2013
Beginner
656 pages
16h 42m
English
EXPLORATION 7
![]()
For Loops
Explorations 2 and 3 show some simple while loops. This Exploration introduces the while loop’s big brother, the for loop.
Bounded Loops
You’ve already seen while loops that read from the standard input until no more input is available. That is a classic case of an unbounded loop. Unless you know beforehand exactly what the input stream will contain, you cannot determine the loop’s bounds or limits. Sometimes you know in advance how many times the loop must run; that is, you know the bounds of the loop, making it a bounded loop. The for loop is how C++ implements a bounded loop.
Let’s start with a simple example. Listing ...
Read now
Unlock full access