Question
Write a program(source code) based on the Part E template and the following instructions. You MUST use (or follow) one formula in Section C and
Write a program(source code) based on the Part E template and 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
D. Pseudocode
Note.The pseudocodes above show the logics only. Students need to take care of the C/C++ language. Only iostream and iomanip are allowed to use in the program.
Part E template
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; E. Template The following template MUST be used. #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started