Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
     #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    bool myfunction (int p,int q)
    {
    return (p < q);
    }
    int main ()
    {
    int var[] = {90, 80, 70, 60, 50};
    vector<int> Num(var, var + 5);
    partial_sort (Num.begin(), Num.begin() + 4, Num.end());
    partial_sort (Num.begin(), Num.begin() + 4, Num.end(),
    myfunction);
    for (vector<int> :: iterator Iter = Num.begin(); Iter != Num.end(); ++Iter)
    cout << ' ' << *Iter;
    return 0;
    }
    1. 50 60 70 80 90
    2. 50 60 70 80
    3. 50 60 70
    4. 50 60
    5. 50
Correct Option: A

In this program, We are partial sorting the vector by using the partial sort method.



Your comments will be displayed only after manual approval.