// program prints the smallest integer #include #include int main() { try{ int i(0); int smallest(32767); do{ std::cout << "Type in a positive integer "; std::cout << "(Zero or a negative number ends the program): "; std::cin >> i; if(not std::cin) { std::cout << "The smallest value so far was " << smallest << '\n'; throw std::exception(); } if (i < 1) break; if (i < smallest) smallest = i; }while(true); std::cout << "The smallest number input was " << smallest << '\n'; } catch(...) { std::cerr << "***An exception was thrown.***\n"; } }