
Lesson 6-5: Debugging
Looping | 143
Name __________________________________________ Date _______________________
Section _________________________________________
Exercise 1: Program SumNums reads and counts non-negative integers until there are no more
data values. You run the program using file sumNums.d1, and the program says that there are no
values on the file. You know that there are nine values on the file and that seven of them are non-
negative. Locate the bug and describe it.
Exercise 2: The program now runs, but it gives the wrong answer. Locate and describe this bug.
Exercise 3: The answer is different but still wrong! Keep looking. Describe ...