Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double f(double x){
- return x*x*x+2*x*x-2;
- }
- double zeroFinder(double min, double max){
- double mid=(max+min)/2.0;
- if (f(mid)<=0.00001 && f(mid)>=-0.00001){
- return mid;
- } else if (f(mid)>0.00001){
- return zeroFinder(min, mid);
- } else {
- return zeroFinder(mid, max);
- }
- }
- int main(void) {
- printf("%f", zeroFinder(0.0, 1.0));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment