Code

darpan.kattel

Darpan Kattel

• Jan. 2, 2022, 7:11 p.m.

Find the sum of the series, take input of x and n.

(x^0/0!)+(x^1/1!)+(x^2/2!)+...+(x^n/n!)

C

#include 
#include 
unsigned int factorial(int n){
    if(n==0){
        return 1;
    }
    return n*factorial(n-1);
}
int main() {
    int xni=0;
    double sum = 0temp;
    printf("Enter the value of x and n:\n");
    scanf("%d %d", &x, &n);
    while(i<n){
        temp=pow(xi)/factorial(i);
        sum+=temp;
        i++;
    }
    printf("The sum of the series is: %.2lf"sum);
    return 0;
}
Output:
Find the sum of the series, take input of x and n. | Output of C Language Code

Add comment:

Total 0 comments