Write a program that will sum the integers between a given range (limit your range from 0 to 50). For example, if the user want to add the integers between (and including) 1 and 10, then the program should add:

Write a program that will sum the integers between a given range (limit your range from 0 to 50). For example, if the user want to add the integers between (and including) 1 and 10, then the program should add:

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

Don't use plagiarized sources. Get Your Custom Essay on
Write a program that will sum the integers between a given range (limit your range from 0 to 50). For example, if the user want to add the integers between (and including) 1 and 10, then the program should add:
Just from $8 /Page 0r 300 words
Order Now

Algorithm:

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now
  1. Program title/description
  2. Ask the user to input a start value in the range 0 to 50. Remember to create the user prompts.
  3. Ask the user to input a stop value in the range 0 to 50. (NOTE: the stop value should be greater than the start value) Remember to create the user prompts.
  4. Use a loop to iterate through the integers in the range, adding to the sum each time the loop executes.
  5. Output the start value, stop value, and the sum of the integers in between.

Test data (Use this data to test to ensure your program does the math correctly.):

  • Start value: 1
  • Stop value: 10
  • Sum: 55

#include <iostream>
using namespace std;
int main() {
//Declaring variable start,stop and sum
int start, stop, sum = 0;
//Prompt input from users Start value
cout << “Start value: “;
//accepting Start value
cin >> start;
//Prompt input from user Stop value
cout << “Stop value: “;
//accepting stop value
cin >> stop;
//looping from start to stop value
for (int i = start; i <= stop; i++)
//adding each value with sum
sum += i;
//printing out the sum
cout << “Sum: ” << sum << endl;
return 0;
}

add error checking to it.

Check the user’s start value to see if it falls within the accepted range. If it doesn’t, the program should tell the user that their input wasn’t in the accepted range and ask the user to reenter a value within the range.

Do the same thing with the stop value.

Once both values are determined to be within the accepted range, then continue with the program.

 

In: Computer Science

Looking for a similar assignment? Get help from our qualified experts!

Order Now