Write a program that adds the sum of the given number.

Sample Output:

Enter the range of number to be added: 5
The sum of 1 to 5 is 15

#include <iostream>

using namespace std;
int main()
{
int n,t,i;
cout << "Enter the range of numbers to be added: ";
cin >> n;
for (t=0,i=1; i<=n ; i++) {t+=i;}
cout << "The sum of 1 to " << n << " is " << t <<endl;
return 0;
}