Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help complete the program below in C language. The square root of a number A can be computed by successive approximations using the iterative

Please help complete the program below in C language.

The square root of a number A can be computed by successive approximations using the iterative formula

Xn+1 = (1/2) ( Xn + A/Xn )

Starting with X1 = 1 as an initial approximation for the square root of A a new approximation X is computed using the above formula. This new approximation, in turn, can be substituted in the formula to compute a newer approximation of X. This process can be continued until the square of the new approximation is close enough to A, that is

| X2 A | < e

where e is the prescribed degree of accuracy.

Write a program to compute the square root of a number using the procedure described above. The number and the level of accuracy will be specified as command line arguments.

For example, if the program was launched with the following command line,

bash> a.out 24 .001

the output of your program should be a line that states something like this

The square root of 24 is 4.899.

Note: You should check out the function fabs.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

What is comparability and to what does it apply?

Answered: 1 week ago