0

I have been working on this lab for a couple of days. I need to write a program (using a 'for loop') that approximates pi using the following series:

pi = sqrt(6* (1/(1)2 + 1/(2)2 + 1/(3)2+ 1/(4)2 + 1/(5)2 +...... + 1/(n)2)) where n is the number of terms. Make the interger datatypes = long, and the floating point datatypes to long double.

This is the code I have written so far. I don't know what i'm missing but the results I'm getting is not correct.

```
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
long int terms, count;
long double pi;
double sqrt;
cout << "Enter the number of terms to use: " << endl;
cin >> terms;
for (count =1; count <= terms; count++);
{
pi = (1.0 /(terms * terms));
}
pi = sqrt * pi;
pi = pi * 6;
cout <<setprecision (15)<< "The approximate value of pi is: " << pi << endl;
system ("pause");
return 0;
} // end main
```