Home > Back-end > To bosses guidance; using the following formula for cos (x) approximation, and accurate to the last
To bosses guidance; using the following formula for cos (x) approximation, and accurate to the last
Time:12-01
Topics are as follows:
The code below
# include & lt; Stdio. H> # include & lt; Math. H>
Double funcos (double e, double x);
Int main () { Double e, x;
Lf the scanf (" % % lf ", & amp; E, & amp; X); Printf (" cos (. % 2 f)=%. 6 f \ n ", x, funcos (e, x));
return 0; } Double funcos (double e, double x) { Double t=1.0; Double l=1.0; Int I; Int j=2; Double the total; Double sum; While ((t/l) & gt; E)//when does not meet the precision cycle { T=pow (x, j); For (I=1; I & lt;=j; I++) { L *=I;//for molecular }
Total +=- (t/l);//a single
The sum +=total;
J +=2;//increment index + 2 } Return the sum + 1; }
I think that no problem, but the code is wrong, where I went wrong, don't see
CodePudding user response:
Your custom function, total and sum uninitialized,
In addition, the output of the double should use % lf, should be a % of the building Lord. 2 lf