0

So I have an assignment to write a program that calculates and prints the sum of the series for the following series:

S = 1/(1*2) + 1/(2*3) + 1/(3*4) + ... + 1/(n*(n+1))

I know I basically need to loop and increment a variable till it equals n, but I don't know what I'm doing wrong in my code

```
//Program to calculate and print the sum of a series
#include <iostream>
using namespace std;
int main ()
{
//declare variables
int n; //input variable
int x(1);
double term(0);
double sum(0); //sum of series
//prompt user
cout << "Please enter the value of n in the series of form sum=sigma(1/(n)*(n+1)): ";
//accept input
cin >> n;
//calulate series using loops
while (x<=n)
{
term += 1/(x*(x+1));
sum += term;
x++;
}
cout << "The sum of the series is " << sum <<endl;
return 0;
}
```

Please help!