Question: Write a program(source code) based on the following instructions. You MUST use (or follow) one formula in Section C and the corresponding pseudocode given in

Write a program(source code) based on the following instructions.

You MUST use (or follow) one formula in Section C and the corresponding pseudocode given in Section D. The function setprecision(int n) is allowed for all formulas and pseudocodes. No function or library function is allowed.

C. Background Knowledge What is Pi? It is the ratio of the circumference of a circle to its diameter. It is a constant for any circle. Some well-known approximations are 3.14, 3.1415926, 22/7, ; however, none of them is the true value of Pi. Even worse, there is no way to represent it as a decimal number with finite digits, or a fraction with integer numerator and denominator. How do we express the value of Pi accurately? We give formulas for Pi as follows:

Write a program(source code) based on the following instructions. You MUST use

D. Pseudocode (or follow) one formula in Section C and the corresponding pseudocode given Note, different modules have different requirements on precision. The pseudocodes above show the logics only. Students need to take care of the C/C++ language.

Formula 3: 2 TT 2 Pseudocode 3: Translated from formula 3. Declare previous, current, product, i, with suitable data types. previous = -20, current = -10; product = 1, i = 1; 2i As long as (current - previous > 0.0000000000000001) do 2i product (product) 2i-1) 2i+1 increase i by one; previous = current; current = 2*product; . Output "Work of student 3"; Output the last value of i; Output current with 9 digits after decimal point

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!