#include int sqroot(const int x, const int min, const int max) { const int mid = (min + max) / 2; const int seen = mid * mid; if (min > max) { cout << x << " has no integer square root\n"; return -1; } if (seen == x) return mid; if (seen > x) return sqroot(x, min, mid - 1); return sqroot(x, mid + 1, max); } int main() { cout << "Enter a number: "; const int x = read_int(); const int y = sqroot(x, 0, 1000); if (y != -1) cout << "The square root is " << y << "\n"; }