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(5);
    fill (VectorData.begin(), VectorData.begin() + 4, 5);
    fill (VectorData.begin() + 1, VectorData.end() - 2, 4);
    for (vector<int> :: iterator Iter = VectorData.begin(); Iter != VectorData.end(); ++Iter)
    cout << ' ' << *Iter;
    return 0;
    }
    1. 5
    2. 5 4
    3. 5 4 4 5 0
    4. 5 4 4 5
    5. 5 4 4
Correct Option: C

In this program, We filled out the vector values by using criteria in the for loop.



Your comments will be displayed only after manual approval.