Write a C program to implement exponential series.
#include<stdio.h>
#include<math.h>
main()
{
float sum;
int i,n,x;
long int fact(int);
printf("\n\n\t\t SUMMATION
OF EXPONENTIAL");
printf("\n\t\t
*************************\n");
printf("\nINPUT:");
printf("\n*******");
printf("\n Enter the Value
of x:\n");
scanf("%d",&x);
printf("\n Enter the Number
of Term:\n");
scanf("%d",&n);
sum=1;
for(i=1;i<=n;i++)
{
sum=sum+(pow(x,i)/fact(i));
}
printf("\nOUTPUT:");
printf("\n******");
printf("\n Exp(x) value : %f\n",sum);
printf("\n Built in Function
for Exp(x) : %f\n",exp(x));
getch();
}
long int fact(int n)
{
int i;
long int f=1;
for(i=1;i<=n;i++)
f=f*i;
return(f);
}
0 comments:
Feel free to contact the admin for any suggestions and help.