E-series calculation



#include
#include "math.h"
int fact(int i);
main()
{
float x;
int n,i=1;
float term=0.0,sum=0.0;
printf("\nEnter the limit : ");
scanf("%d",&n);
printf("\nEnter the value of x : ");
scanf("%f",&x);
x=x*(3.14/180.0);
for(i=0;i{
term=(pow(x,i))/fact(i);
sum=sum+term;
}
printf("\nValue of sum is (i.e e(x)) : %f\n",sum);
}
int fact(int n)
{
int i,s=1;
for(i=1;i<=n;i++)
s=s*i;
return s;
}

No comments: