if (cin.fail() || area < 0) cout << "Input error.\n"; if (r >= 0 && -b / 2 + sqrt(r) >= 0) ...
if (!cin.fail()) quarters = quarters + n;