# Thread: programing with pi, canīt get it

1. ## programing with pi, canīt get it

Hi guys, I have the next program as assignment, but because english is not my first language, i just canīt get what it really wants me to do, could any of you explain it to me in a simplier way please?

The number π, or 3.1415..., can be calculated from the infinite series
π = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 ...
Query the user for the number of terms to use in the approximation, and then calculate π. Then ask if they wish to repeat using a different number of terms. Indicate in your email the approximate number of iterations required to calculate π to six decimal places. Use double instead of float for extra precision.

Hint: This lab is easy to solve if you store the numerator and denominator in separate variables.

2. 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.