Completion requirements
Read this chapter, which explains while loops. This is in contrast to how a do-while loop works, which we will discuss later. In a do-while loop, the body of the loop is executed at least one time, whereas in a while loop, the loop may never execute if the loop condition is false.
11. Web Page Version of the Program
Answer:
count is: -2
count is: -1
count is: 0
count is: 1
Zero is included in the list of values!
Web Page Version of the Program
You might enjoy playing with this JavaScript version of the program. Try a variety of initial and limit values. Predict what the loop does for each choice.
If the output does not fit into the text area, use the "scroll bar" on the right to move up and down through the output.
(The output window sometimes shows messages that would not be printed by the example code.)
Question 11:
Try entering an initial value of 9 and a limit value of 4. What happens? Why?