**/IGNORE**

My requirements are to write a program that finds pi like: ∏ = 4 – 4/3 + 4/5 – 4/7 + 4/9 – 4/11... etc + . It needs to prompt user for the number of times to run the above equation. I.E. only once would equal 1, running it twice would give you 4-4/3 so 2.67. Lastly it wants the user to enter the the number of times the program should display the results. I.E. if a user wants 100 values of pi done every 10, it should print 10 results. I.E. Pi @ 10 = 3.048

pi @ 20 =... etc up to 100. All of the input, needs to be done in a user defined function, and the display count should also be done in the user defined function.

**/END IGNORE**

Here is an example of what is wanted:

Enter the number of terms to use: 500

Display Pi after every how many steps? 0

ERROR – Input must be positive and non-zero! Please try again.

Display Pi after every how many steps? 100

RESULTS:

100: Pi = 3.131592904

200: Pi = 3.136592685

300: Pi = 3.138259330

400: Pi = 3.139092657

500: Pi = 3.139592656

Final Pi = 3.139592656

You can ignore my code if you want, im not really asking for an answer, just an example of a similar problem that can let me figure mine out. I want to learn this, im just confused on how to out put this to main in the correct form.

Here is my code, it is very jumbled as i threw it together. Just an example of where I am at. My out at 10 values of pie, results every 1 works fine. However, 10 values of pie at 2 results, is not correct.

int userInput(); int main () { double numer; //numerator double denom; //denominator int pi, check, test; double input, num, num2, math, output; pi = userInput (); cout << pi; cout << endl << endl; system("PAUSE"); } int userInput(){ double output, input, num, num2, math, numer; int test, check; test = 0; numer = 1; math = 0; do{ cout << "Enter the number of terms to use: "; cin >> check; if (check <= 0){ cout << endl << "ERROR - Input must be positive and non-zero! Please try again." << endl << endl; } } while (check <= 0); do{ cout << endl; cout << "Display Pi after every how many steps? "; cin >> input; if (input <= 0){ cout << endl << "ERROR - Input must be positive and non-zero! Please try again." << endl << endl; } } while (input <= 0); num = input; num2 = 1; while (test < check ){ if (test % 2 == 0) math = math - (4 / numer); else if (test % 2 == 1) math = math + (4 / numer); numer += 2; test++; input = num; input = input * test; num2++; cout << input << " " << -math << endl; } cout << endl; return check; cout << endl; }