Home › Forums › C Programming › Approximate the value of PI › Reply To: Approximate the value of PI

September 4, 2008 at 2:03 am
#3446

glimpse

Participant

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 | <br /> if (sum%2==0)<br /> sum=sum+1/y;<br /> else sum=sum-1/y;<br /> //The I would put this part into brackets {}.if (i%2==1){ <br /> if (sum%2==0)<br /> sum=sum+1/y;<br /> <br /> else<br /> sum=sum-1/y;orif (i%2==1)<br /> if (sum%2==0)<br /> sum=sum+1/y;else sum=sum-1/y;<br /> |