Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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