Computer Science, asked by baskar98428, 5 months ago

write an algorithm for finding the square root of the given number

Answers

Answered by dhruvsh
0

Answer:

Surely, there's no question of using an inbuilt square root function in an available library, we'll have to think of a good algorithm that the machine can do for us

So, suppose the input number is a and we are supposed to find the square root of this number

Run a while loop with the condition that

(i^2 - a)((i+1)^2-a)<0

Then,

Surely, √a lies between i and i+1

So, now, take the mean of i and i+1 which is i+1/2

Now, again check

if (i^2-a)((i+1/2)^2-a) < 0 then, √a lies between i and i+1/2 Repeat the process further taking mean of i and i+1/2 that is i+1/2

Else, take the mean of i+1/2 and i+1 = i + 3/4 and repeat the process to the accuracy you want and the machine can handle for the float value.

Hope this helps you !

I assume here that you needed just the algorithm and can write the code in any language you prefer with the corresponding syntax.

Answered by pdchowdary7488
0

Explanation:

write an algorithm to find the square root of a number

Similar questions