adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <vector>
    #include <iostream>
    #include <typeinfo>
    #include <stdexcept>
    using namespace std;
    int main()
    {
        vector<int> vec;
        vec.push_back(10);
        int i = vec[100];
        try {
            i = vec[0];
            cout << i << endl;
        }
        catch (exception &e)
        {
            cout << "Caught: " << e.what( ) << endl;
            cout << "Type: " << typeid( e ).name( ) << endl;
        }
        catch (...) 
        {
            cout << "Unknown exception: " << endl;
        }
        return 0;
    }

a.

10

b.

100

c.

Exception

d.

Error

Answer: (a).10

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?