Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function to calculate the square root of a float number with the following interface: double squareRoot( double x) ll assert that x is
Write a function to calculate the square root of a float number with the following interface: double squareRoot( double x) ll assert that x is not negative The function should return an approximation to vx using series approximation. Let xox/2. Then x+xnx)2. Keep computing terms until the difference between xn and x1 is less than 0.0001. In addition, if the input variable x is negative, your function should stop the execution via the assert) function, which is a built-in C++ function. You need to add a function call to assert() at the beginning of the above function to guarantee the precondition of this function is correct. In your main function, design it to request the user to enter as many numbers as they want (continue to enter values? "y" or "n"). Test cases must include values 3,0, and -3, as well as others you think are appropriate. The specifics of the assert message shown depends on the specific implementation in the compiler, but it should include: the whose assertion failed, the name of the source file, and the line number where it happened. A usual expression format is: Assertion failed: file filename, line line number #include void print_number (int myInt) [ assert (myInt > 5); e program will abort iI my
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