Introduction: Debugging Interlude—Debugging Loops

Here are the prerequisites, learning objectives, and overview for this debugging interlude.

We'll cover the following

Prerequisites

Learning objectives

After completing this chapter, you should be able to:

  • Choose a data set that thoroughly tests a program’s logic
  • Trace the execution of a loop
  • Deal with loops whose erroneous logic fails to end its repetition

Overview

After introducing the while statement, we noted some typical errors programmers might make when coding a repetitive process. Loops that cycle one too few times, one too many times, or forever are common problems that we should try to avoid. These kinds of mistakes are not peculiar to the while statement; they can be made just as easily when writing for statements and do statements. Although our goal is to avoid mistakes, how do we find those that we do make?

Get hands-on with 1400+ tech skills courses.