answersLogoWhite

0

I am not familiar with C but I can tell you the following which will be of use:

First of all it is simply impossible to find the exact value of pi. Pi is an irrational number which has an infinite number of digits which do not repeat with any pattern. Therefore the best you can ever hope to do is to find an approximation for pi. There are different ways to do this and I will show you two below. These methods calculate an approximation of pi by adding together a series of terms. The more terms that are added together the more precise the answer will be. These methods can therefore be used no matter which computer language you are using.

Method 1.

Pi2 / 6 = (1/12) + (1/22) + (1/32) +(1/42) + (1/52)... to infinity

You can therefore write a loop which will add together these terms by simply adding 1 to a variable each time the loop executes. When you have done this however many times you wish (and remember that the more times the loop runs the more precise our answer will be) you then multiply the result by 6. This value is then equal to an approximation of pi squared. You therefore now find the square root of the result!

Method 2

Using similar principles to the above but using a different formula:

Pi / 4 = (1/1) + (-1/3) + (1/5) + (-1/7)... to infinty

Thus Pi / 4 = (1/1) - (1/3) + (1/5) - (1/7) to infinity

Again the pattern whilst slightly harder, is still easy to spot, and can be written as a loop in a computer program where a variable is changed on each loop and run as many times as desired.

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

RossRoss
Every question is just a happy little opportunity.
Chat with Ross
JudyJudy
Simplicity is my specialty.
Chat with Judy
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran

Add your answer:

Earn +20 pts
Q: How do you find value exact value of PI in C language?
Write your answer...
Submit
Still have questions?
magnify glass
imp