Advertisement
daniv1

29.6

Oct 29th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 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.     int cnt = 0;
  13.     for(;fabs(x) <= 2.0 + eps; x+=0.05)
  14.     {
  15.         printf("f(%.2lf) = %.4lf\n",x,f(x));
  16.         if(f(x) > 1.0)
  17.         {
  18.             cnt++;
  19.         }
  20.     }
  21.     printf("cnt = %d\n",cnt);
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement