C Program Exponential e raise to x

This Program finds the Exponential using a simple C Program. This is a part of Mumbai University MCA Colleges C Program Sem 1


#include<stdio.h>
#include<conio.h>
#include<math.h>
double fact(double);
double po(double s)
{
double p=1.0,i,sum=1.0,val,f1;
for(i=1;i<=50;i++)
{
p=s*p;
f1=fact(i);
sum=(p/f1)+sum;
}
return(sum);
}

double fact(double n)
{
double ans=1.0,i;
if (n==0.0)
{
return(1);
}
for(i=1;i<=n;i++)
{
ans=ans*i;
}
return(ans);
}

void main()
{
double x;
clrscr();
printf("Enter the value of x \t");
scanf("%lf",&x);
printf("\nThe Value of power of e to x is %lf",po(x));
getch();
}


Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

No comments:

Post a Comment