Functions


  1. Which keyword is used to declare the min and max functions?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Algorithm header file contain the supporting files needed for the execution of these functions.


  1. How many parameters does a operator() in a function object shoud take?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In the case of binary function objects, this operator() member function will take two parameters.



  1. Which are instances of a class with member function operator() when it is defined?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Function objects are instances of a class with member function operator() defined. This member function allows the object to be used with the same syntax as a regular function call.


  1. What is the output of this program?
    #include <iostream>
    #include <functional>
    #include <algorithm>
    using namespace std;
    int main ()
    {
    int num[] = {11, -22, -33, 44, -55, 66, -1};
    int Calculate;
    Calculate = count_if ( num, num + 7, bind2nd(less<int>(), 0) );
    cout << Calculate;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    In this program, We are calculating the number of negative elements present in the program by using function objects.



  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. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

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