Home > Back-end >  Is there a big tell me why (why) run out the correct answer?
Is there a big tell me why (why) run out the correct answer?

Time:04-06

#include
#include
Int main ()
{
Double PI=0.0, the term=0.5;
Int j, I, n.
While (fabs (term) & gt; E=1-6)
{
for(i=1; I> 0; I=I + 2)
J=j * I/(I + 1);
(n=1/(I + 2) * pow (2, I + 2));
The term=j * n;
PI=PI + term;
}
PI PI=6 *;
Printf (" PI=% 10.8 f \ n ", PI);
return 0;
}
Pray for formula of PI PI/6=1/2 + 1/2) (x/3 x (1/2) Sunday afternoon 3 + 1/2 x (3/4) * (1/2) Sunday afternoon 5 + 1/5 (1/2 x 3/4 (5/6) * (1/2) Sunday afternoon 7 1/7...

CodePudding user response:

Modified as follows, for your reference:
 # include 
#include
Int main ()
{
Double PI=0.5, the term=0.0, n, j=1.0;
Int I=1;

Do {
//for (I=1; I> 0; I=I + 2)
J=j * I/(I + 1);
N=1.0/(I + 2) * pow (0.5, I + 2);
The term=j * n;
PI=PI + term;
i+=2;
} while (fabs (term) & gt; E=1-6);
PI PI=6 *;
Printf (" PI=% 10.8 f \ n ", PI);

return 0;
}
  • Related