CS 150 Introduction to C++ Programming - Spring 1998 

[ Home | Lecture Notes| WebTutor | WebTutor Site Map]


Loop Iterations


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

How many iterations does the following loop perform?

This feature does not work on your browser - you need to be Java enabled!!

 

Choose one when done
   

Copyright chris wild 1998.
For problems or questions regarding this web contact [Dr. Wild (e-mail:wild@cs.odu.edu].
Last updated: February 26, 1998.