Your assignment wants you to use a loop and the series it gave you, to calculate pi.

The good tip is to keep the numerator (top number of the fraction), in a separate variable from the bottom number of the fraction.

You may want to put the real Pi number, into a string, and then you can count (inside your outer loop), the number of digits of resolution you have calculated, that matches up with the real Pi digit:

Code:

Pistr[]="3.14159265358979"; //you may need more digits
Now put your currently calculated number into a string of your own, and compare it, char by char
while(Pistr[i] == myPi[i++] );
--i; //backtrack one time

Your calculation is correct to i digits. When i equals the number of digits of resolution you need, your program is done, so this is the stop condition for your outer loop (while or for).

what you need to do is to get started and post up what you have done, and what has you stumped atm.

Then we can be more helpful.