Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

the value of pi can be approximated by using the fllowinseries pi = 4(1-1/3+1/5-

ID: 3617835 • Letter: T

Question

the value of pi can be approximated by using the fllowinseries pi = 4(1-1/3+1/5-1/7+...) writea valu returning function nmed almostpi, which hasaninteger parameter n. The function cmputes and returns anapproximation for i which use n-many terms in the series. For exaple, i n = 2, the function returns the value of4(1-1/3). if n = 5, the following returns the valu of4(1-1/3+1/5-1/7+1/9). the main prgam asks the user to input the value o n: How manytims do you want in the approximation of pi?" Then it calls thefunction, and outputs the value which the function returns. the value of pi can be approximated by using the fllowinseries pi = 4(1-1/3+1/5-1/7+...) writea valu returning function nmed almostpi, which hasaninteger parameter n. The function cmputes and returns anapproximation for i which use n-many terms in the series. For exaple, i n = 2, the function returns the value of4(1-1/3). if n = 5, the following returns the valu of4(1-1/3+1/5-1/7+1/9). the main prgam asks the user to input the value o n: How manytims do you want in the approximation of pi?" Then it calls thefunction, and outputs the value which the function returns.

Explanation / Answer

please rate - thanks #include using namespace std; double calcpi(int); int main() { int terms; coutterms; cout