Question: Write a C++ program that can calculate the approximate value of pi using the series below. You can get an approximate value for pi using

Write a C++ program that can calculate the approximate value of pi using the series below.

You can get an approximate value for pi using the below mathematical series:

pi=4[1/1-1/3+1/5-1/7+1/9-...)

Each item can be calculated using the formula (-1)i / (2i+1)

The program should take an input num that determines the number of terms in the approximation of pi and outputs the approximation.

Variables should be: num as into and pi as double

Input will be num

Process: Use a counting loop, translate the above mathematical series formula into a computer formula to get an approximation of pi based on num iterations of the loop.

Output will be pi

Example:

Enter num 100

PI ~ 3.15149

Enter num 2

PI ~ 3.46667

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!