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

Im stuck on a C++ code. I need it to ask the user again for another value after

ID: 654932 • Letter: I

Question

Im stuck on a C++ code. I need it to ask the user again for another value after it gives the answer. note i want it to repeat everything before cout "thank you for using our program"

please make sure to reset the variables. thanks

#include<iostream>

using namespace std;

int main()

{

                double pi = 0;

double sum = 0;

                int i, j, sign, x;

                cout << " This Program Approximates the value of pi using the taylor series for arctan" << endl;

                cout << " Please Enter a number for the nth term: ";

                cin >> x;   //this reads the nth term from the user

                i = 1;

                j = 1;

                sign = 1;

                while (j <= x)

                {

                                sum = sum + (1 / double(i) * sign); //this says 1/odd numbers

                                i += 2; // This gives the denominator odd numbers

                                sign = sign * (-1); // this alternates the sign

                                j++;

                }

                pi = sum * 4; // this multiplies the sum of the terms by 4

                cout << " Approximate Value of PI is " << pi << endl;

                cout << " Thank You for using our program!" << endl;

                cin.ignore();

                cin.get();

                return 0;

}

Explanation / Answer

#include<iostream>
using namespace std;

int main()
{
Char choice;
double pi = 0;
double sum = 0;
int i, j, sign, x;
cout << " This Program Approximates the value of pi using the taylor series for arctan" << endl;
cout << " Please Enter a number for the nth term: ";
cin >> x; //this reads the nth term from the user
i = 1;
j = 1;
sign = 1;
cout<<