adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    bool myfunction (int i,int j) { return (i<j); }
    int main () 
    {
        int myints[] = {9, 8, 7, 6, 5};
        vector<int> myvector (myints, myints + 5);
        partial_sort (myvector.begin(), myvector.begin() + 3, myvector.end());
        partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(), 
        myfunction);
        for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
            cout << ' ' << *it;
        return 0;
    }

a.

5 6 7

b.

5 6 7 9 8

c.

9 8 7 6 5

d.

None of the mentioned

Answer: (b).5 6 7 9 8

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?