Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions