Thread: Finding pi through computing area of a quarter circle -error---

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2015
    Posts
    2

    Finding pi through computing area of a quarter circle -error---

    please help me . I have one day

    question: Finding pi through computing area of a quarter circle


    Finding pi through computing area of a quarter circle -error----image003-png
    my code


    Code:
    #include <iostream>
    #include <cmath>
    #include <iomanip>
    
    using namespace std;
    
    int main()
    {
      
        double sum,PI,h,x=0;            
        while (x<=2)
        {
        
        h=sqrt((2*2)-(x*x));    
        x=x+(2./20000.);
        sum=sum+h;
        }
        PI=sum*(1./10000.);
        cout << " Pi value is " <<setprecision(50)<<PI <<     
        system("pause");
        
        }
    HOW can i fix it ?
    The program cannot precisely find the value of pi.
    result is
    Code:
    3.14169223
    expect value: 3.1415926535
    Last edited by helloworld1123; 05-04-2015 at 07:18 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Area of Circle Without Pi
    By Jhernandez860 in forum C++ Programming
    Replies: 7
    Last Post: 04-08-2013, 01:24 PM
  2. Area of a circle error, help
    By spazx in forum C Programming
    Replies: 16
    Last Post: 09-14-2010, 06:25 PM
  3. finding area of unit circle by monte carlo..
    By niceguy in forum C Programming
    Replies: 4
    Last Post: 02-25-2008, 01:32 PM
  4. area of a circle
    By wise_ron in forum C Programming
    Replies: 2
    Last Post: 10-02-2006, 03:15 PM
  5. Circle Area
    By Zophixan in forum C++ Programming
    Replies: 3
    Last Post: 11-05-2002, 12:50 PM