Advertisement
daniv1

29.5

Oct 29th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define eps 0.000001
  5. double f(double x)
  6. {
  7.     return x + pow(x,2);
  8. }
  9. int main()
  10. {
  11.     double x = 1.5;
  12.     double min = f(x);
  13.     double max = f(x);
  14.     for(;fabs(x) <= 2.0 + eps; x+=0.05)
  15.     {
  16.         printf("f(%.2lf) = %.4lf\n",x,f(x));
  17.         if(f(x) > max)
  18.         {
  19.             max = f(x);
  20.         }
  21.         if(f(x)<min)
  22.         {
  23.             min = f(x);
  24.         }
  25.     }
  26.     printf("max = %.4lf\n",max);
  27.     printf("min = %.4lf\n",min);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement