6
Loading subject content…
Loading subject content…
Loading practice questions…
What will be the output of the program?
#include <iostream>
using namespace std;
#include <stdexcept>
int main() {
try {
throw out_of_range("bad index");
} catch (const exception &e) {
cout << e.what() << endl;
}
return 0;
}What will be the output of the program?
#include <iostream>
using namespace std;
void f() { throw 5; }
void g() { f(); cout << "g"; }
int main() {
try { g(); } catch (int v) { cout << v; }
cout << endl;
return 0;
}What will be the output of the program?
#include <iostream>
using namespace std;
int main() {
try {
throw 42;
} catch (int e) {
cout << "int " << e << endl;
} catch (...) {
cout << "other" << endl;
}
return 0;
}