i need a program that will do this
if 4 is inputted the sum is 10 but it will display this 1+2+3+4 before it shows the sum can anyone help?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# include <iostream>
usingnamespace std;
int main()
{
int sum = 1;
int num;
for(int i=1;i<num;i++)
cin>>num;
{
cout << sum << " ";
sum += i;
}
return 0;
}