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

In this program, We filled up all the vector values by using fill method.



Your comments will be displayed only after manual approval.