small program to calculate e

the program goes like this:

it should calculate the value of e^x by the series

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

when the user inputs a value , eps , which the program has to stop compute e^x when x^n/n<eps.

I wrote 2 function , one calculating the factorial result (fact), and one calculates the value x^n/n! (monom).

these functions works well, but the program keeps giving me 1 as result for e^x (or it gets stuck..)

it seems that the problem comes from the condition monom (x,j)<eps, but I can't see why...

Code:

`#include <stdio.h>`

#include <math.h>

float fact (int);

double monom (float x, int n);

int main (void)

{

float x;

printf ("please enter x value for e^x: ");

scanf ("%f", &x);

double exp=1;

float eps;

printf ("please enter delta: ");

scanf ("%f", &eps);

int j;

for (j=1; monom (x,j)<eps; j++)

exp+=monom (x,j);

printf ("%f",exp);

return 0;

}

float fact (int a)

{

float result=1;

int i;

for (i=1;i<=a;i++)

result*=i;

return result;

}

double monom (float x, int n)

{

return (pow(x,n)/fact(n));

}

can you guys help me? thanks a lot!