+ 1
If i have done some mistake so please explain.
Sum of series 1+2+4+7+11....+n terms https://code.sololearn.com/cKq3NG8yYF8A/?ref=app
8 Answers
+ 18
#include <stdio.h>
int main() {
int i,N,term=1,sum=0;
//â term for current term
//â variable sum for summing up terms
//clrsr()
printf("enter the value of N:\n");
scanf("%d",&N);
for(i=1;i<=N;i++)
{
sum=sum+term; //â for adding terms to sum variable
term=term+i; //â for getting to next term
}
printf("sum of series:%d",sum);
//â printing sum here , not N
return 0;
}
+ 13
Lata Mishra
â in your code, U have used sum variable [it was not calculating sum of N terms, but it was calculating (N+1)th term of series]
//see comments I made in above answer for better understanding đ
+ 4
line no. 12
printf("sum of series :%d", sum);
you are supposed to print the sum not the input
+ 4
which term?
+ 4
term is the difference between two consecutive numbers that are to be added
term for 1 and 2 is 1
term for 2 and 4 is 2
term for 4 and 7 is 3
and so on...
+ 2
Still confused why i need to use "term"
+ 2
Used by Gaurav agrawal
+ 2
Ok
but you should first explain mistakes and talk respectfully