Hi I would like to know how I can write a program that gives me the sum of 1 to n numbers. Example:

Code:

#include <iostream>
using namespace std;
int main ()
{
int i =0;
//Here is a loop that, for example, gives me numbers from 0 to 4
//My problem is, I want to add these numbers
//I get 01234, now all I want is add them together
//I was thinking of maybe using an array to save these numbers, then add them
//one by one but I am a beginner and have no idea how to do it
for (i; i<5; i++)
{
cout<<i
}
return 0;
}

Thanks in advance!