#include
#include
#include
#define PI 3.1415
float exp_x(int,int);
int fact(int);
void main()
{
int x,n;
printf("Enter the value of x:");
scanf("%d",&x);
printf("Enter the value of n:");
scanf("%d",&n);
printf("\nValue of e^x is ",exp_x(x,n));
getch();
}
float exp_x(int x,int n)
{
int i=1;
float ex=1;
while(i
ex+=(float)pow(x,i)/fact(i);
++i;
}
return ex;
}
int fact(int num)
{
int f=0;
if(num==1)
return 1;
else
f=num*fact(num-1);
return f;
}
No comments:
Post a Comment