Advertisement
semsem_elazazy

Untitled

Dec 17th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7.    
  8.    int x,n;
  9.    int i,j,fact=1;
  10.    float sum=1;
  11.     printf("Enter the value of  X to calculate e^x \n X : %d",x);
  12.    scanf("%d",&x);
  13.   printf("Enter the number of terms \n N :%d",n);
  14.    scanf("%d",&n);
  15.    
  16.    for(i=1;i<=n;i++)
  17.    {
  18.        for(j=i;j<=n;j++)
  19.        {
  20.           fact=fact*j;
  21.           break;              
  22.        }        
  23.        if(i==j)sum=sum+pow(x,i)/fact;    
  24.    }
  25.    printf("e^x = %f",sum);
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement