Wyo C++ Ch. 8 Worksheet #1 - writing loops |
Name - |
Do the following exercises on lined paper.
1. Write a for loop that efficiently displays the even numbers between and including 2 and 16. Declare and initialize all necessary variables.
2. Write a while loop that efficiently displays the even numbers between and including 2 and 16. Declare and initialize all necessary variables.
3. Write a for loop that efficiently displays the multiples of 3 between but not including 54 and 24 in descending order. Declare and initialize all necessary variables.
4. Write a full C++ program that uses a bottom-checking loop to allow the user to enter a sequence of integers and obtains the sum of those inputted values. The sentinel value -99 should indicate that the user does wishes to end the program (but -99 should not be added to the sum of inputs.) The program should display the final sum.
5. Convert the program that you wrote in #4 to one that uses a top-checking determinant loop.
6. Convert the program that you wrote in #4 to one that uses a definite loop.