Home » C++ Programming » Functions » Question
  1. What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    bool mygreater (int i,int j)
    {
    return (i > j);
    }
    int main ()
    {
    int Numbers[] = {45, 55, 55, 45, 65, 45, 55, 65};
    vector<int> num(Numbers, Numbers + 8);
    pair<vector<int> :: iterator, vector<int> :: iterator> Bound;
    sort (num.begin(), num.end());
    Bound = equal_range (num.begin(), num.end(), 65);
    cout << (Bound.first - num.begin());
    cout << " And " << (Bound.second - num.begin());
    return 0;
    }
    1. 6
    2. 8
    3. 6 And 8
    4. 8 And 6
    5. None of these
Correct Option: C

In this program, We are finding out the equal range in the vector.



Your comments will be displayed only after manual approval.