C program to evaluate exponential series upto limit n

Exponential series is of the form

e^x=1+x/1!+x^2/2!+x^3/3!+...x^n/n! 

This C program calculates the factorial and the value of exponential function upto a limit n.

#include<stdio.h>
#include<math.h>
int fact(a){
int fact=1,i=1;
while(i<=a){
fact*=fact;
i++;

}
return fact;
}

int main(){
int n,i=0;
float x,sum=0;
printf("enter limit");
scanf("%d",&n);
printf("Enter value of x");
scanf("%f",&x);
for(i=0;i<=n;i++){
sum+=pow(x,i)/fact(i);

}
printf("%f",sum);

}

 

Output