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

Approximating PI using a series. The series approximation of PI is given by the

ID: 3652334 • Letter: A

Question

Approximating PI using a series.

The series approximation of PI is given by the expression:
pi=??i=1(?1)i+1(4/(2i?1))=4[1?(1/3)+(1/5)?(1/7)+(1/9)?(1/11)+(1/13)....]

The PI Approximation Program: Write a program consisting of only the main function, called piApproximator.cpp. When your program begins, the user is prompted to enter a number n representing the number of terms to be used in the approximation. Your program should then compute the series approximation of PI using the first n terms of the series described above and display that approximation.
If the user enters a non-positive integer for the number of terms, your program should indicate that the number entered is invalid. Your program should display the series approximation to twenty decimal places.
Sample Run 1:
This program approximates pi using an n-term series expansion.
Enter the value of n> -3
-3 is an invalid number of terms.
Sample Run 2:
This program approximates pi using an n-term series expansion.
Enter the value of n> 1
pi[1] = 4[1] = 4.0000000000000000000
Sample Run 3:
This program approximates pi using an n-term series expansion.
Enter the value of n> 6
pi[6] = 4[1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11] = 2.97604617604617560644
Sample Run 4:
This program approximates pi using an n-term series expansion.
Enter the value of n> 10
pi[10] = 4[1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13 - 1/15 + 1/17 - 1/19] = 3.04183961892940146754

Explanation / Answer

#include#include#include void main() { clrscr(); int num; float pi=4.0; do { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote