Question 8. Exception handling [ 10 marks ]

Show the output from the following program:

#include <iostream>
#include <string>
using namespace std;

void f1();

int main()
{
    try {
        cout << "Try block in main" << endl;
        f1();
    }
    catch (string s) {
        cout << "string: " << s << endl;
    }
}

void f1()
{
    try {
        cout << "First try block in f1" << endl;
        throw(1.1);
    }
    catch (double d) {
        cout << "double: " << d << endl;
    }
    catch (float f) {
        cout << "float: " << f << endl;
    }
    try {
        cout << "Second try block in f1" << endl;
        string s = "10";
        throw(s);
    }
    catch (int i) {
        cout << "int: " << i << endl;
    }
}