while
Loop
Exercise:
Use ex1_count.cpp
in the replit team project or copy the following code into your IDE:
When it is complete, this program will allow the user to add together any
number of integers. It will use a while
with two variable - one for the loop counter, and one for the total number
of loop repetition. The user first types how many numbers they wish to add,
then types the numbers one at a time pressing enter after each one.
Please input the number of integers that you would like to add: 5
Enter an integer value: 3
Enter an integer value: -2
Enter an integer value: 0
Enter an integer value: 9
Enter an integer value: 1
The sum of the 5 integers is 11
ex1_count.cpp
.
©Department of Computer Science, University of Regina.