Approximate the value of PI

Home Forums C Programming Approximate the value of PI

This topic contains 2 replies, has 2 voices, and was last updated by  RandiHoltermann 9 years, 3 months ago.

  • Author
    Posts
  • #2133

    Hi guys. I’m pretty new to C program. I’ve been given this assignment to write a program that asks the user thow many terms of the serires equation to use in approximating PI. The formula given is pi=4X(1- 1/3 + 1/5 – 1/7 + 1/9 – 1/11 + 1/13 – ….)

    Here is the script that I’ve written but I’m stuck. Please advice. My alogarithm might be wrong

  • #3446

    glimpse
    Member

    I don’t understand so much from mathemics, but a problem migth be, that your variable i is an integer value.
    Something else: What should happen, if (i%2==1) ?
    I expect you mean the hole part:

  • #3447

    Thanks for your input. The following is the working scripts

You must be logged in to reply to this topic.

0 Shares
Share
+1
Tweet
Share
Stumble