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 ...