adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main () 
    {
        vector<int> myvector (5);
        fill (myvector.begin(), myvector.begin() + 4, 5);
        fill (myvector.begin() + 3,myvector.end() - 2, 8);
        for (vector<int> :: iterator it = myvector.begin();
            it != myvector.end(); ++it)
        cout << ' ' << *it;
        return 0;
    }

a.

5 5 5 5 0

b.

8 8 8 8 0

c.

5 8 5 8 0

d.

5 5 5 5 5

Answer: (a).5 5 5 5 0

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?