I appologize for putting this code up again, but I can not find where it is not looping this time again and I don't think it's a simple mistake like last time.
There are some other errors with it such as a is displaying too inaccurate of a number for the single loop that it does but I first want to get the loop to work then I could fix the problem with a.Code://The program checks to see how many parameters it takes to near Pi using the equation 4X(1-1/3+1/5-1/7+1/9-1/11....)
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double pi = 3.14195;
double a = 1, p = 1;
double n = 3, sign = -1;
bool check = true;
int finish = 0, t = 0;
do
{
while (check)
{
a += sign*(1.0/(n)); //the equation
sign = -sign; // reversing the signs
t++; // counting how many parameters are needed to near Pi
n+= 2;
if (a*4 <= pi + 1*(pow(10,-(p+1))) && a*4 >= pi - 1*(pow(10, -(p+1)))) //checking if it is close enough to Pi
check = false; //breaking loop if it is close enough to Pi
}
cout << fixed << setprecision(p);
cout << a*4 << " " << t << endl;
finish++; // adding 1 for each loop completed up to the limit of 6
p++; //adding 1 to the power and precision decimal places
t = 0; //reseting counter
a = 1; //reseting a
check = true; //switching check back to true to loop while again
}while(finish < 6);
return 0;
}