Question: Pi Calculation implementation. Pi = 4 * (1/1 1/3 + 1/5 1/7 + 1/9 (alternating + -) (1/n)) Then notice that the denominator goes from

"Pi Calculation implementation. Pi = 4 * (1/1 1/3 + 1/5 1/7 + 1/9 (alternating + -) (1/n))

Then notice that the denominator goes from 1,3,5,7,9 etc. So this is counting by 2s starting at one. For loops are good when you know how many times it will go through the loop. So a for loop might be something like:

for (long i=1; i

C= c+ (pow (-1,i)/(2i+1)) where i is the term that changes by 2 starting at 1 (not zero)

Write a c++ program to calculate the approximate value of pi using this series. The program takes an input n that determines the number of values we are going to use in this series. Then output the approximation of the value of pi. The more values in the series, the more accurate the data. You will try it with numbers read in from a file. to see the accuracy increase. Use a for loop for the calculation and a while loop that allows the user to repeat this calculation for new values n until the user says they want to end the program." I believe I have the user inputted code down, but I'm struggling to think of the code that takes the information from the .txt file to calculate to pi. The text file looks like:

"12

123

1234

12345

123456

1234567

12345678

123456789"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!