Search for question
Question

#4: Series expansion for pi. Allow user to enter the number of terms to be summed in

the series expansion. Display the final value of pi. Execute with a variety on number of

turns (5, 10, 50, 100, 1000, 5000, etc) and record results for each. (Use either a "for"

loop or "while" loop. Each loop iteration adds another term.) Include appropriate output

and test cases. Hint: use FOR loop, ex: for (k = 0; k

Formula:

pi= 4*(1-1/3 + 1/5 - 1/7 + 1/9-1/11 + 1/13 + ...)

For example, if user enters the number of terms = 3, then

pi= 4*(1-1/3 + 1/5); // sum the 3 terms

Question: how do you alternate (change) the sign (+ to -)? Hint: use -1

Submit 4 programs to Angel: F2Cfor.cpp, F2Cwhile, missile.cpp, piseries.cpp

OR. Avanzato

39

Fig: 1