Implementation of exp function in C using Taylor Series expansion
Termination condition not correct

To get the precision you request, you should stop the loop when x1 &lt;= e, not when x1 / x0 &lt;= e.  If you do that, you can now get rid of x0 because it no longer serves a purpose.  I adjusted your program to use the new termination condition and it gave me the results I believe you are looking for.  I also renamed e to precision because it was confusing for a variable to be named e when it didn't actually hold the value of the constant \$e\$.

#include &lt;stdio.h&gt;
#include &lt;math.h&gt;

int main(void) {
    double x1,precision,x,sum=0.0;
    int n=0;
    scanf("%lf %lf",&amp;x,&amp;precision);

    // Sums: 1 + x + x^2/2! + x^3/3! + x^4/4! + x^5/5! + ...
    //
    // To get an approximation of e^x.
    //
    // Stops when the next term to add becomes smaller than precision.
    x1=1;
    do {
        sum += x1;
        x1  *= (x/++n);
    } while (x1 &gt; precision);

    printf("sum=%lf,\nexp=%lf\n",sum,exp(x));
    return 0;
}