Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <vector>
    #include <iterator>
    using namespace std;
    int main ()
    {
    vector<int> VectorData;
    for (int k = 0; k <= 8; k++)
    VectorData.push_back(k);
    VectorData.erase (VectorData.begin() + 6);
    VectorData.erase (VectorData.begin(), VectorData.begin() + 4);
    for (unsigned k = 0; k < VectorData.size(); ++k)
    {
    cout << ' ' << VectorData[k];
    }
    return 0;
    }
    1. Compilation Error
    2. Runtime Error
    3. 4 5 7 8
    4. 4 5 7
    5. None of these
Correct Option: C

In this program, We are erasing the values in the vector based on the given condition.



Your comments will be displayed only after manual approval.