SUMMATION OF EXPONENTIAL SERIES
#include”stdio.h”
#include “conio.h”
#include
int fact(int);
void main()
{
int i;
float x,sum=1,p,f,n,c;
clrscr();
printf("\n Enter the values of x and n : ");
scanf("%f %f",&x,&n);
for(i=1;i<=n;i++)
{
p=pow(x,i);
f=fact(i);
c=(p/f);
sum=sum+c;
}
printf("\n Summation of Exponential series : %f",sum);
printf("\n\n Exp(%.0f) : %f",x,exp(x));
getch();
}
int fact(int a)
{
int f=1,i;
for(i=1;i<=a;i++)
f=f*i;
return(f);
}
Output will be
Enter the values of x and n : 2 3
Summation of Exponential series : 6.333333
Exp(2) : 7.389056
No comments:
Post a Comment