What is the formula for Pi that I can use in C++?

Printable View

- 10-11-2003zowenFormula for Pi
What is the formula for Pi that I can use in C++?

- 10-11-2003velius
Pi is a constant of 3.1415926535897932384626433832795 which is usually labeled as 3.14. There would be no formula for that.

- 10-11-2003Dante Shamest
An

**approximation**would be 22/7. - 10-11-2003zowen
no..there is definitely a formula.

- 10-11-2003Dave_Sinkula
There is this, but in C I might do something like the following.

Code:`double pi = 4.0 * atan(1.0);`

- 10-11-2003curlious
Did you try a search on google.

Here is one link.

PI - 10-11-2003joshdick
There are plenty of ways to calculate Pi. When you get to Calc 3, you'll learn about series and use them to find approximations for Pi and

*e*. If you just need to use Pi in a program, declare PI as a constant that has as many decimal places as you want of accuracy. - 10-12-2003Shiro
There are many ways to calculate pi. Note that if you want to calculate pi during the running of your program, this may be very inefficient. Better would be to store pi as a constant and use that constant. Ofcourse you'll always work with approximations of pi.

Here are some links on calculating pi:

http://mathworld.wolfram.com/PiApproximations.html

http://mathworld.wolfram.com/PiFormulas.html

http://www.myownlittleworld.com/pi/links.html