how do you find the square root of a number in C without using the predefine function sqrt()
please help if you can
mail me at
[email protected]
how do you find the square root of a number in C without using the predefine function sqrt()
please help if you can
mail me at
[email protected]
This might help.
zen
would be better to use the predefined if you saw the source code abouve in the link; that is a lot of work.
It's not that much work. Alot of the code if the link was for handling user input, the function that computes the square root was just -
Code:void NewtonRaphson (float accuracy, int userIn, float *answer) { /* Local defs * float guess = 1.0; float div2 = (float)userIn/2; while (1) { guess = (div2+ userIn/div2)/2; if((fabs (guess-div2) < accuracy))break; div2 = guess; } *answer = guess; }
zen