daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <conio.h>
  4.  
  5.  
  6.  
  7. float func(float x);
  8. float sum(float x, float eps);
  9. void main()
  10. {
  11. float x,y,s,eps;
  12. printf("Vvedite eps: ");
  13. scanf("%f", &eps);
  14. if (eps<0) eps=0;
  15. for (x = 0.5; x <= 0.751; x=x+0.05) {
  16.  s=sum(x,eps);
  17.  y=func(x);
  18.  printf("x=%4.2f => s=%f, y=%f \n", x, s, y);
  19. }
  20. getch();
  21. return;
  22. }
  23. //
  24. float func(float x)
  25.  {
  26.  return (1-cos(x))/x/x-sin(x)/x+0.5;}
  27.  
  28. //
  29. float sum(float x, float eps)
  30.  {
  31.  int n;
  32.  float t,a,b;
  33.  t=0;
  34.  n=1;
  35.  a=-1;
  36.  while (fabs(a)>eps)
  37.   {b=-x*x/(2*n-1)/(2*n+2)/2;
  38.   a=a*b;
  39.   t=t+a;
  40.   n=n+1;}
  41.  return t;}
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