Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main ()
    {
    vector<int> VectorData;
    for (int k = 0; k < 5; ++k)
    VectorData.push_back(k);
    reverse(VectorData.begin(), VectorData.end());
    for (vector<int> :: iterator Iter = VectorData.begin(); Iter != VectorData.end(); ++Iter)
    cout << ' ' << *Iter;
    return 0;
    }
    1. 4 3 2 1 0
    2. 4 3 2 1
    3. 4 3 2
    4. 4 3
    5. 4
Correct Option: A

In this program, We reversed the vector values by using the reverse function.



Your comments will be displayed only after manual approval.