Continuing from the question I posted before How to increase precision for function e^x
I made few changes in my code by taking advices given
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long double exponential(long double x, long double n, long double p)
{
long double i = 1;
while (n > 0) // loop stops when becomes less than 0
i = i + (x / p) * (exponential(x, n - 0.0001, p + 1));
if (n < 0) // when n reaches 0 or becomes less than zero value of i will be returned
return i;
}
int main()
{
long double p, x, n;
scanf("%Lf", &x);
printf("math.h e^x = %lf\n", exp(x));
printf("calculated e^x = %Lf\n", exponential(x, 1, 1));
return 0;
}
But I am not getting any output its just giving run time error(http://codepad.org/jIKoYGFC) and I don't know why . Please can some one help me why I am getting these errors