Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions