Question: C programming Problem 2 (15 pts): Unit testing (functions)-sec 5.7 in Zybook a) (9 pts) The square root of a number x can be approximated

 C programming Problem 2 (15 pts): Unit testing (functions)-sec 5.7 in

C programming

Problem 2 (15 pts): Unit testing (functions)-sec 5.7 in Zybook a) (9 pts) The square root of a number x can be approximated by the repeated application of the following Newton-Raphson formula: y-new-y-old + x/y-old) where y_ new is the new estimate of the square root of x and y old is the previous one. al) Write a C user-defined function that calculates the square root of any positive number with an accuracy of 10. That is, the new and the old estimates differ by less than 10. Function prototype: double root(double x); a2) In the main function, use assert() (see sec 5.7 (Figure 5.7.2) in your Zybook) to test your "root" function. ASSERT your function by running unit tests for test values: 0,4, 10, 10000, 0.25, 7.85, and 9.8696. One example for testing square root of 10 is assert(fabs(root(10) - 3.16228)

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!