// program prints the smallest positive or negative integer #include #include int main() { try{ int i(0); int smallest(2147483647); do{ std::cout << "Type in a positive or negative integer "; std::cout << "('-2147483648'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 == -2147483648) 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"; } }