The factorial() function could be shortened a bit:

```
//using a 64bit int
unsigned long long factorial(int n) {
unsigned long long r = 1;
while(n > 1)
r *= n--;
return r;
}
```

And for the sum() function, I would use the #defined constant instead of defining it yourself.

```
#include <math.h>
#include <float.h> // Required for DBL_EPSILON
double sum(double x) {
double sum = 1;
int i = 2;
double addVal = pow(x,(double)i)/factorial(i);
while(addVal > DBL_EPSILON) {
sum += addVal;
i++;
addVal = pow(x,(double)i)/factorial(i);
}
return sum;
}
```

BTW, nice thinking about the EPSILON thing.