#include using namespace std; int divide(int x, int y) { if (y == 0) throw runtime_error("division by zero"); return x / y; } int main() { int * x; try { x = new int[100]; x[0] = divide(7, 0); } catch (bad_alloc & e) { cout << "Failed because of bad memory allocation\n"; x = NULL; } catch (exception & e) { cout << "Failed because of " << e.what() << "\n"; x = NULL; } cout << "x = " << x << "\n"; delete [] x; }