We're supposed to write a program that will approximate a square root using a recursive function. For some reason, I cannot get it to return the proper numbers. I ran an error check using some printf's and it seems like the lower value is not being replaced when it should be. Can anyone help me out? Here is my function:
Code:double square_root(double low, double high) { float mid; mid = (high + low) / 2; //Base Case if((mid*mid) == high) return mid; //Stops when the high and low numbers are within 0.001 of one another. if((high - low) < 0.001) return mid; if((mid*mid) > high) return square_root(low, mid); return square_root(mid, high); }