Ok I know one way of using the formula n*(n+1)/2) and have used it to calculate the sum already but I just wanted to know how I can access many numbers in a loop and add them together. Here is what I did so far.

Code:`#include <iostream>`

using namespace std;

int main (){

int num, num1, sum;

cout<<"Please enter a number\n";

cin>>num;

cout <<"Please enter the number to which you want to count\n";

cin>>num1;

for (; num<=num1; num++)

cout<<num<< ","; //I do get the numbers but from here

//I want to know what I can do so that I can add each

// of these numbers together?

do (sum=num+num);//I want to add them like 0+1+2+...

//tried using loops but couldn't get it

while (num<=sum);

cout<<sum;//but this does not work so any help is appreciated

return 0;

}