Loading video...
Looping
- Loops execute a code block more than once, as many times as needed
- Early computing used “goto” – modern computing uses various explicit looping constructs
- “while” loop, tests an expression for “true” before each loop – code block may be skipped completely if expression starts off “false”
- “do-while” loop, tests an expression for “true” after each loop – code block is guaranteed to run at least once
- “for” loop, usually has an explicit loop counter – code block is looped a very specific number of times
- “break” leaves a loop early
- “continue” returns to the beginning of a loop
- Nested loops operate on each sub-item of each item
- Nested loops should use different counters and different termination expressions, otherwise subtle bugs may be introduced
- Here is a link that discusses various kinds of C++ loops: http://www.cplusplus.com/doc/tutorial/control/
Looping
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.
- Intro
- Overview
- Important Kind of Branch
- Branch That Loops
- In The Beginning
- 'While' Loop - Pre-Test
- 'Do-While' Loop - Post-Test
- 'Do-While' Run It Again
- 'For' Loop-Counting Loops
- 'For' Loop-Most Typical Use
- 'For' Loop - Similar to 'While'
- 'Break' Out of Loop
- 'Break' Examples
- 'Continue' Back to Beginning
- 'Continue' Caution
- Loop Inside of Loops
- Typical Bug
- More Looped Loops
- What a Loop!

































Start Learning Now
Our free lessons will get you started (Flash® 10 required).
Sign up for Educator.comGet immediate access to our entire library.
Features Overview