0

hi.. ok here is my problem

i want to make a fuction that ask from the user which series he/she wants to use and the precision (number of digits, up to 10). If after

10000 iterations the series doesn't find the value of p, it

should display an error message.

It will display either an error message or the value of p and

the number of iterations necessary to obtain that value.

In order to round a real number to n decimal places.

here is my code, i post my code only for first series so if you have any ideas please help me:

Pi == 3.141592653589793

Example:

Which series do you want?

2

How many digits of accuracy ?

5

The Series 2 is approximate on 1000 iterations.. pi = 3.14159

or

The Series 2 is not approximate, try another series...

```
double pi=0,seriesValue=0;
const double counter=3.141592653589793;
if (series='2')
{
cout<<" Series 2"<<endl;
cout<<" ----------"<<endl;
cout<<""<<endl;
cout <<"How many digits of accuracy?;
cin>>digits;
for (long int n = 1; n <= 10000; n++) //for loop for SERIES 2
{//for loop start
serieValue+= pow(-1.0, n+1)/pow(n,2.0); // Calculating pi
pi=sqrt(12*serieValue);
if (pi1==counter)
{ //if start for coutner
cout<<"The Series 2 is approximate on "<<n<<" iterations pi of series 2 == "<<fixed<<setprecision(digits)<<pi1<<endl;
} //if end for coutner
else
cout<<"Error"<<endl;
} // for loop end
} //if end for series 2
```