All pastes #2129443 Raw Edit

Mine

public text v1 · immutable
#2129443 ·published 2012-03-18 04:50 UTC
rendered paste body
Mid-Term Quiz 2. Develop a C++ program that prompts the user to enter a start number and an end number.
//The program calculate the summation of the numbers.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int start = 0;
	int end = 0;
	int sum;

	cout << "Enter the start number: \n";
	cin >> start;

	while(start !=0)
	{
		cout << "Enter the end number: \n";
		cin >> end;

		if(end == 0)
			break;
		else
			if(end > start)
				cout << "Start number must be bigger than the end number"<<endl;
		        break;
		for (int i = start; i <= end; i++)
				sum += i;
		cout << "The total of all integers from " << start << " to " << end << " is " << sum << endl;
		sum = 0;
		cout << "Enter the start number: ";
		cin >> start;
	}

	system("pause");
	return 0;
}