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;
        for (int i = 1; i < 5; ++i)
            myvector.push_back(i);
        rotate(myvector.begin(), myvector.begin() + 3, myvector.end( ));
        for (vector<int> :: iterator it = myvector.begin(); 
            it != myvector.end(); ++it)
        cout << ' ' << *it;
        return 0;
    }

a.

1 2 3 4

b.

4 3 2 1

c.

3 4 2 1

d.

4 1 2 3

Answer: (d).4 1 2 3

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?