Question: The C++ code below uses float type variables x, y, z, and square. It computes the square root of the variable square by repeatedly moving

The C++ code below uses float type variables x, y, z, and square. It computes the square root of the variable square by repeatedly moving x and y closer together so that x*x <= square and y*y >= square until they are so close that either one could be used as the square root. Complete the code below by making the compound statement {...} into a do/while loop that continues until the difference y-x is smaller than 0.001. You may use the literal constant 0.001 in your answer. x = 0.0; y = 100.0; { z = (x + y) / 2.0; if (z*z > square) y = z; else x = z; } 

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!