try { int d = 0; while( cin >> d ) cout << 10 / d << "\n"; } catch(...) { cout << "division by zero\n"; }