Home » C++ Programming » Functions » Question
  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. 11
    2. 4
    3. -22
    4. -33
    5. -44
Correct Option: B

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



Your comments will be displayed only after manual approval.