Question: Hi here is a c++ program used to guess the value of pi. However, i encountered some troubles. If you put 0, it gives 4,

 Hi here is a c++ program used to guess the value

Hi here is a c++ program used to guess the value of pi. However, i encountered some troubles. If you put 0, it gives 4, which is correct. But as for the other numbers, it just gives back zero. I couldn't find the error and I am pretty sure my logic is correct. Can anyone run this and detect the problem? Btw enter (-1) means to exit the program.

#include #include using namespace std; int main int n-0,pi-0, m-0,1imit-0: cout.setf (ios::fixed); cout.setf (ios:showpoint) cout.precision (3); while (n !=-1) { cout>n; if (n= (-1)){ return 0: for n-0 ; ( limit { m=m+1) (pow (l'1,n)) / (24 m

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!