The Babylonian algorithm to compute the square root of a number n is as follows:
1. Make a guess at the answer (you can pick n/2 as your initial guess).
2. Compute r = n / guess
3. Set guess = (guess +r ) / 2
4. Repeat steps 2 and 3 three more times. Note, the more that steps 2 and 3 are repeated, the closer guess will become to the square root of n . Complete the following program so that it inputs an integer for n , iterates through steps 2 and 3 as mentioned above, and outputs the answer as a double to two decimal places. Your answer will be most accurate for small values of n .
CodeMate Hints: Make guess a double using type casting, static_cast<double>(n)
This is a simple algorithm.
if you're having trouble with it, draw a flowchart for this algorithm and it can help you understand better.
but if you want us to do YOUR HOMEWORK, I'm afraid that's not possible.
It's not an assignment; i'm just taking some online lessons on C++ and faced this problem :)
If you wanna help, then help. If you don't want, then keep your silly comments to yourself :)
Thank you