C Program to Implement e^x Function

This C Program finds the value of exponential function e^(x),given x and n

[cc lang=”c”]
#include
#include
int x;
int n,u;
int fact(int n)
{
if (n==1)
return (1);
else
return(n*fact(n-1));
}

int findex()
{
int sum=0,ex,numr,denr;
int i;
for(i=0;i<=n;i++) { numr=pow(x,i); denr=fact(i); ex=numr/denr; sum+=ex; } printf("ne^x = %d t %d n",sum,ex); } main() { printf("Enter the Value for 'X' and 'N' and Upper Limitn"); scanf("%d %d %d",&x,&n,&u); findex(); } [/cc]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *