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};
        vector<int> myvector (myints, myints + 4);
        partial_sort (myvector.begin(), myvector.begin() + 2, 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.

6 7 8 9

b.

9 8 6 7

c.

6 7 9 8

d.

None of the mentioned

Answer: (c).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?