Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<windows.h>
  4.  
  5.  
  6. int main()
  7. {
  8.  
  9.  
  10. double a1 = 0.0,
  11. aPrev = 0.0,
  12. s = 0.0,
  13. n = 0.0,
  14. dif = 0.0,
  15. x = 0.0,
  16. c = 0.0,
  17. eps = 0.00000001;
  18.  
  19.  
  20. printf("x = ");
  21. scanf_s("%lf", &x);
  22. a1 = x;
  23. aPrev = a1;
  24. n++;
  25. s = a1;
  26. do
  27. {
  28. c = (-4.0*n*n*x*x-2*n*x*x);
  29. s = s + aPrev*c;
  30. dif = aPrev*c - aPrev;
  31. aPrev = aPrev*c;
  32. printf("%.8lf\n", fabs(dif));
  33. n++;
  34. break;
  35. } while (fabs(dif) > eps);
  36.  
  37. printf("Sum = %.8lf", s);
  38.  
  39. system("pause>0");
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement