#include
#include
Fac (int n);
Int main ()
{
Float x, f, funcvalue, approx=0;
Int n=0;
Cout<& lt;" Both please enter the index of e: "& lt;
Funcvalue=https://bbs.csdn.net/topics/exp (x);
Cout
While ((abs (approx - funcvalue)) & lt; 1 e - 12)
{
F=fac (n);
Approx=(x, n) approx + pow/f;
N++;
}
Cout<& lt;" E ^ "& lt;
}
Fac (int n)
{
Float f;
If (n==0)
return 1;
The else
F=fac (n - 1) * n;
Return the f;
}
CodePudding user response:
abs (approx - funcvalue)) & lt; 1 e - 12you want to ensure that this condition is met can go in, you input - 13, you can go in... And your fac (int n) didn't write a return type, not an error? The correct writing is float fac (int n);
CodePudding user response:
Should be greater than the right, while ((abs (approx - funcvalue)) & gt; 1 e - 12)CodePudding user response:
While ((abs (approx - funcvalue)) & gt; 1 e - 12) set breakpoints, step through look at the conditions to meet?CodePudding user response:
Fac function has no return value type?CodePudding user response:
Abs is the absolute value function of integer and floating point Numbers is fabs, this phrase: while ((abs (approx - funcvalue)) & lt; 1 e - 12) change, change to the while ((fabs (approx - funcvalue)) & lt; 1 e - 12), you continue to check there are no other errors