Answered step by step
Verified Expert Solution
Link Copied!

Question

...
1 Approved Answer

Suppose you have a calculator with no square root button, but you really need to calculate the square root of x . What do you

Suppose you have a calculator with no square root button, but you really need to calculate the square root of x . What do you do? You guess! (Carefully, of course.) For example, suppose you need to calculate 27 . You would first guess that 1 is your answer. Definitely not close enough because 1^2 is not close to 27. A second better guess is (1 + 27/1)/2, which is 14. Still not close enough because 142 is not close to 27. A third better guess is (14 + 27/14)/2 = 7.9642..., which is still not close enough, but is closer! Keep going until your guess is accurate enough. If a particular guess, n, is not close enough to being an accurate square root of a number x, we can produce a new and better guess by calculating (n + x/n) / 2. For your algorithm, "accurate enough" means accurate to three decimal places. 0. Declare variables

0.1 Declare X as number inputted

0.2 Declare GUESS as current guess

0.3 Declare TEMP as current squared value

  1. Input square root

1.1 Output "Insert the number to be square rooted"

1.2 X <- keyboard

2.GUESS <- 1

3. TEMP <-1

4. Loop while TEMP != X

4.2 TEMP <- N * N

4.3 N <- (N + X/N) / 2

5. Output "The square root of", X, "is estimated to be", N

6. STOP That is my answer, please help fix it and correct it

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Health Care Management

Authors: Sharon B. Buchbinder, Nancy H. Shanks

3rd Edition

9781284081015

Students also viewed these Algorithms questions

Question

Write short notes on RMS Value of AC waveforms.

Answered: 1 week ago

Question

7. Write a note on electrical safety

Answered: 1 week ago

Question

8. What are the basic concepts of household wiring and explain?

Answered: 1 week ago