Using a Sentinel Value to Control a while Loop
In this exercise, you use what you have learned about sentinel values. Study the following code, and then answer Questions 1-5.
1. What is the output if the user enters a 6?
_____________________________________________________________________________________
2. What is the problem with this code, and how can you fix it?
_____________________________________________________________________________________
3. Assuming you fix the problem, if the user enters 50 as the number of pages to print, what is the value of counter when the loop exits?
_____________________________________________________________________________________
4. Assuming you fix the problem, if the user enters 0 as the number of pages to print, how many pages will print?
_____________________________________________________________________________________
5. Assume you have fixed the problem discussed in Question 2, and then you delete the curly braces. Now, what is the output if the user enters 5 as the number of pages to print?
_____________________________________________________________________________________
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.