# include # include # include using namespace std; int main ( ) // // SQROOT_DO_WHILE estimates a square root using a DO...WHILE statement. // { double error, h, w, x; cout << "Enter number whose square root is desired: "; cin >> x; h = x; w = x / h; error = x - h * h; while ( 0.00001 < fabs ( error ) ) { h = ( h + w ) / 2.0; w = x / h; error = x - h * h; } cout << "\n"; cout << "Number X = " << x << "\n"; cout << "Estimated square root = " << h << "\n"; cout << "Error | x - h * h | = " << error << "\n"; return 0; }