Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that uses Newton's method to compute a squareroot. Objectives: Do-while looping Error cheek the user with a while loop if negative number
Write a program that uses Newton's method to compute a squareroot. Objectives: Do-while looping Error cheek the user with a while loop if negative number entered Successful implementation of an algorithm Learn the fabs function Define a tolerance Sample Output: Enter a positive number: 3 Enter a guess: 1 squareroot: 1.73205 Newton's Method: Let x be the number entered by the user. Newton's method requires an initial guess y for the squareroot of x. In the example below, the guess is 1. Successive guesses are found by computing the average of y and x/y. The following table shows how the squareroot of 3 would be found: Note that the values of y get progressively closer to the true squareroot of x. For greater accuracy, your program should use variables of type double rather than float. Have the program terminate when the absolute value of the difference between the old value of y and the new value of y is less than .00001
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started