Cannot finish this code on C++?

sherry_ellis88

New member
THIS IS THE QUESTION: Write an application that shows the sum of 1 to n for every n from 1 to 50. This is the program prints 1 (the sum of one alone), 3 (the sum of 1 and 2), 6 (the sum of 1, 2, and 3), 10 (the sum of 1,2,3 and 4) and so on and so on.

THIS IS WHAT I HAVE DONE SO FAR:
# include <iostream>
# include <conio.h>
using namespace std;
int main()
{
int sum=0;
for(int i = 1; i<=51; i++)
sum = sum +i;
cout << sum + "n";
}

_getch ();
}

ERRORS: They are on lines: 9,12 and 13
 
Back
Top