+ 2
How to find the sum of following series using "1+(1+2)+(1+2+3)+(1+2+3+4)+.......N" the value of N is entered by the user.
Question regarding loop in C++. Making a program on series.
4 Answers
+ 4
#include <iostream>
using namespace std;
int main ()
{
int n;
cin>>n;
int answer =0, before=0;
for (int i=1; i <=n: i++)
{
before += i;
answer += before;
}
cout<<answer <<endl;
return 0;
}
// I dont compile and run my code, correct me if i wrong
+ 3
https://code.sololearn.com/ciIe19fPYB1w/?ref=app
Sorry its in C# but hopefully it can help you.
Good luck.
+ 3
int main()
int n,sum,sum1=0,i,j;
printif("please enter a number");
scanf("%d",&n);
for(i=1; i<=n,i++)
sum=0
for(j=1;j<=i;j++);
sum=sum+j
sum1=sum1+sum;