Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <vector>
    #include <iostream>
    #include <typeinfo>
    #include <stdexcept>
    using namespace std;
    int main()
    {
    vector<int> Data;
    Data.push_back(56);
    int k = Data[200];
    try {
    k = Data[0];
    cout << k << endl;
    }
    catch (exception &excep)
    {
    cout << "Caught: " << excep.what( ) << endl;
    cout << "Type: " << typeid( excep ).name( ) << endl;
    }
    catch (...)
    {
    cout << "Unknown exception: " << endl;
    }
    return 0;
    }
    1. Compilation Error
    2. 56
    3. 200
    4. 100
    5. None of these
Correct Option: B

In this program, We are pushing the 10th element and printing it.



Your comments will be displayed only after manual approval.