Question
Create a C-Program that will take the square root of a number using a square-root function that corresponse to the following protoype: double mySqrt(double x);
Create a C-Program that will take the square root of a number using a square-root function that corresponse to the following protoype: double mySqrt(double x); (for x => 0)
Please use the Newton-Raphson equation:
Relative error:
-"Find the quare root of" Displays on the screen when ran. User enters a number and hits return, and then the application prints the quare root of the number enter, or an error message if the user enters a negative number.
- The function should check to make sure the number entered by the user is not negative. If the user enters a negative number and that negative number is given to the function mySqrt(x), mySqrt(x) should return -1 as an error code. The main program can check for the error code and decide what message to print to the user if the error code is returned.
- To calculate the relative error, you will need an absolute value function. You can write your own, or use the fabs( ) function from the #include library.
Thank you!
UPDATE:
k+1Step 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