The value of π can be approximated by using the following series:                 The following program uses this series to find the approximate value of π. However, the statements are in the...




The value of π can be approximated by using the following series:





The following program uses this series to find the approximate value of π. However, the statements are in the incorrect order, and there is also a bug in this program. Rearrange the statements and remove the bug so that this program can be used to approximate π.


using namespace std;


int main()


 {


    double pi = 0;


    long i;


         long n;


    cin >> n;


    cout <>


    cout


    if (i % 2 == 0)


        pi = pi + (1 / (2 * i + 1));


    else


        pi = pi - (1 / (2 * i + 1));


    for (i = 0; i <>


    {


        pi = 0;


        pi = 4 * pi;


    }


    cout <>


    return 0;


 }




"pi="">


    return 0;


 }



>




May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here