Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define eps 0.000001
- double f(double x)
- {
- return x + pow(x,2);
- }
- int main()
- {
- double x = 1.5;
- double min = f(x);
- double max = f(x);
- for(;fabs(x) <= 2.0 + eps; x+=0.05)
- {
- printf("f(%.2lf) = %.4lf\n",x,f(x));
- if(f(x) > max)
- {
- max = f(x);
- }
- if(f(x)<min)
- {
- min = f(x);
- }
- }
- printf("max = %.4lf\n",max);
- printf("min = %.4lf\n",min);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement