daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Sep 12th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<math.h>
  4. long int factorial(int n);
  5.  
  6. int main()
  7. {
  8.  int x,i;
  9.  float s,r;
  10.  char c;
  11.  
  12. printf("You have this series:-1+x/1! + x^2/2! + x^3/3! + x^4/4!..x^x/x!");
  13.  printf("To which term you want its sum of ?  ");
  14.  scanf("%d",&x);
  15.  s=0;
  16.  for (i=1;i<=x;i++)
  17.   {   s=s+((float)pow(x,i)/(float)factorial(i));
  18. }
  19.  printf("The sum of %d terms is %f",x,1+s);
  20.  
  21.  fflush(stdin);
  22.       getch();
  23. }
  24.  
  25. long int factorial(int n)
  26.  {
  27.   if (n<=1)
  28.  return(1);
  29.   else
  30.  n=n*factorial(n-1);
  31.  return(n);
  32.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top