Hi Everyone,

For a couple weeks, I have been developing a pi approximation program and making little upgrades. Right now, the program asks for an input of iterations and then prints out the approximation. Now, I want to have every iteration printed out into an excel file with an approximation accurate to

```
.000001 [50,000 iterations]
```

However, I realized that the current setup of my program does not work well, so I think some rework is in order.

So my goal is to eliminate the input process; and instead, base the iterations on accuracy, not input. That is what I would like some help with. The problem is that I do not know how to set up a for loop to go until that accuracy point is reached. The ofstream part I am somewhat proficient at so I will add all that in later.

```
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
//Declare variables
float x;
float y;
int counter;
int n;
int swap;
//Get input
cout << "Please input the number of terms in the series to be calculated." << endl;
cout << "(at least 700 for recognizable accuracy)" << endl;
cin >> n;
x = 0;
swap = 1;
counter = 0;
//Loop
for (int counter = 0; counter != n; ++counter)
{
x += swap * (1.0 / (1 + counter * 2));
swap *= -1;
}
x = 4 * (x);
//Averaging most recent terms
counter = counter - 2;
y = ((swap * (1 / (1 + counter * 2))) + x);
cout << setprecision(15) << "My best approximation of PI is " << y << endl;
cin.get();
cin.get();
//Exit program
return 0;
}
```