Advertisement
rafikamal

Series of e

Jan 22nd, 2013
67
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 1 0
  1. #include <stdio.h>
  2.  
  3. double e(double x);
  4.  
  5. int main()
  6. {
  7.     double x;
  8.    
  9.     printf("Enter x: ");
  10.     scanf("%lf", &x);
  11.    
  12.     printf("e ^ %lf = %lf\n", x, e(x));
  13.    
  14.     return 0;
  15. }
  16.  
  17. double e(double x)
  18. {
  19.     double ans = 0;
  20.     double term = 1;
  21.     int i;
  22.    
  23.     for(i = 1; i < 10; i++)
  24.     {
  25.         ans += term;
  26.         term *= x/i;
  27.     }
  28.    
  29.     return ans;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement