Question: Write a function to calculate the square root of a float number with the following interface: float squareRoot( float x) Il assert that x is

 Write a function to calculate the square root of a float

Write a function to calculate the square root of a float number with the following interface: float squareRoot( float x) Il assert that x is not negative The function should return the vx. In addition, if the input variable x is negative, your function should stop the execution via the assert() function, which is built-in function in C++. You should add a function call to assert() at the beginning of the above function to guarantee the preconditiorn of this function is correct In your main function, you need design two test cases: x-3 andx--3. Create a screenshot to demonstrate the execution of your program in these two test cases. In the case: x--3, there should be an error prompt window. Save this error prompt window as the evidence that you successfully implement the assert function call. Do you think this error prompt window provides you some useful information? Furthermore, set a break point in the main function before calling squareRoot( float x). Then, use step-wise debugging tool to step into this function, and step through the whole function until the program returns to the main function. Use screenshots to record the process, and embed the screenshots into the word document

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!