Question: 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 use fabs function for absolute value for the level of accuracy.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!