Question: Exercise 1 Filename: sum.cpp Prompt the user and let them enter two integers (we'll call them x and y, for the purposes of this writeup).

Exercise 1

Filename: sum.cpp

Prompt the user and let them enter two integers (we'll call them x and y, for the purposes of this writeup). Use a loop to compute and print the sum of the ingeters in the range x through y (including the endpoints). Output should look like the sample runs below, and print the addition details from the smallest to the largest number.

(Note: The user input will not necessarily have the lowest number first -- see Sample Run 2. You must take this into account).

Sample Runs

(user input is underlined, to distinguish it from output)

Sample Run 1

 Input two integers: 10 20 Sum of values from 10 through 20 is: 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 = 165 

Sample run 2

 Input two integers: 9 -4 Sum of values from -4 through 9 is: -4 + -3 + -2 + -1 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 35 

Sample run 3

 Input two integers: 7 7 Sum of values from 7 through 7 is: 7 = 7 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!