CS 150 Introduction to C++ Programming - Spring 1998 |
|---|
[ Home | Lecture Notes| WebTutor | WebTutor Site Map]
How many times does a
loop go?
Each time a loop executes, it is call an iteration of the loop.
Iterate means to count.
It is important to count the iterations of a loop, since a common
programming error is being off in the loop count.
"while" loops can execute 0 or more times. (if the
condition is initially false, then the loop does not execute at
all)
"do while" loops execute 1 or more times (since the
condition is tested at the end it is executed at least once).