Calculate The Value Of E^X Series



Source code :-

#include<stdio.h>
#include<math.h>
int main()
{
    float x,sum=1,f=1;
    int n,i;
    printf("Enter the value of x: ");
    scanf("%f",&x);
    printf("\nEnter the number of terms: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        f=f*i;
        sum=sum+pow(x,i)/f;
    }
    printf("\nThe Result is %.2f\n",sum);
    return 1;
}

Input-Output :-

abhi@hp-15q-laptop:~$ gcc e^x.c -lm
abhi@hp-15q-laptop:~$ ./a.out
Enter the value of x: 10
Enter the number of term: 5
Result = 1477.67

Post a Comment

أحدث أقدم