Question: #include double getvalue ( double , int ) ; int factorial ( int ) ; int main ( ) { int n; double x; double

#include
double getvalue (double, int);
int factorial (int);
int main ()
{
int n;
double x;
double series;
printf("This program calculates e^x
");
printf("using sum of (x^k)/k!
");
printf("Enter x, n : ");
scanf("%lf%d",&x,&n);
printf("x,n =%8.4lf %4d
",x,n);
series = getvalue(x,n);
//printf("e^x =%14.10lf
",series);
printf("e^%lf =%14.10f
", x, series);
return(0);
}
double getvalue (x,n)
double x;
int n;
{
int k;
double value =0.0;
double xpow =1.0;
for (k =0; k <= n; k++)
{
value += xpow / factorial(k);
xpow = xpow * x;
}
return(value);
}
int factorial (number)
int number;
{
int j;
int fact =1;
for (j =1; j <= number; j++)
{
fact = fact * j;
}
return(fact);
}whats wrong with this code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!