Sum of e series

Submitted by Karthikeyan on Sun, 06/09/2009 - 07:01

C Program to find Sum of Exponential series for the given value of x and n


#include 
#include 
main()
{
    int f, i, j, n;
    double x, xt, ex = 0.0;
    printf("\n\t\t Sum of Exponential series");
    printf("\n\t\t*******************\n");
    printf("\nEnter the value of x and n");
    scanf("%lf ",&x);
    scanf("%d", &n);
    for(i=0; i<=n; i++)
    {
        for(f=1, j=1; j<=i; j++)
        f = f*j;
        xt = pow(x, i) / (double)f;
        ex = ex + xt;

    }
    printf("\n The Exponential value = %lf", ex);
    printf("\n The use of library function Exp. value = %lf", exp(x));
    printf("\n\n\t\t********************\n");
}