Write a recursive
function to find square root of a number.
#include "math.h"
#include "float.h"
float MySqrt(float num, float prev)
{
float next = (prev+num/prev)/2;
if (fabs(next-prev)<FLT_EPSILON*next)
return next;
return MySqrt(num, next);
}
To call it, pass
1.0
as
your initial guess for the prev
parameter.