Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double func(double x)
- {
- return x*x-4*x-10;
- }
- int main()
- {
- double a, b, c;
- scanf("%lf %lf", &a, &b);
- while(b-a>.0001)
- {
- c = ((a+b)/2);
- if(func(a)*func(c)<0)
- b=c;
- else
- a=c;
- }
- printf("A root of the equation using bisection method is,\nX = %.4lf\n",(a+b)/2.0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement