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 k,int L)
    {
    return (k }
    int main ()
    {
    int num[] = {10, 11, 15, 13, 25};
    vector<int> VectorData (num, num + 5);
    partial_sort (VectorData.begin(), VectorData.begin() + 3, VectorData.end());
    partial_sort (VectorData.begin(), VectorData.begin() + 2, VectorData.end(),
    myfunction);
    for (vector<int> :: iterator Iter = VectorData.begin(); Iter != VectorData.end(); ++Iter)
    {
    cout << ' ' << *Iter;
    }
    return 0;
    }
    1. 10
    2. 10 11
    3. 10 11 13
    4. 10 11 13 15
    5. 10 11 13 15 25
Correct Option: E

In this program, We are partitioning the value by using the partial_sort method.



Your comments will be displayed only after manual approval.