#include void find_sqrt(int a, int b, int x) // want square root of x, given // that it will be between a and b { const int mid = (a+b)/2; cout << "my guess is " << mid << "\n"; if (mid*mid == x) cout << "I won\n"; else if (mid*mid > x) find_sqrt(a, mid-1, x); else find_sqrt(mid+1, b, x); } void main() { find_sqrt(0, 1000, 6400); } // the mistake on Thursday was that I'd typed this // { guess_at(0, 1000000, 6400); } // so the first guess was mid = 500000, and that gives // mid*mid = 250000000000, which is far too big to fit // in an int.