// This program illustrates exception handling. #include using namespace std; // Function prototype double divide(double, double); int main() { int num1, num2; double quotient; cout << "Enter two numbers: "; cin >> num1 >> num2; try { quotient = divide(num1, num2); cout << "The quotient is " << quotient << endl; } catch (char *exceptionString) { cout << exceptionString; } cout << "End of the program.\n"; return 0; } double divide(double numerator, double denominator) { static char *str = "ERROR: Cannot divide by zero.\n"; if (denominator == 0) throw str; else return (numerator/denominator); }