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[] = {5, 10, 11};
    int Remainder[4];
    transform ( num, num + 4, Remainder,
    bind2nd(modulus<int>(), 2) );
    for (int k = 0; k < 4; k++)
    cout << (Remainder[k] == 1 ? "Odd" : "Even") << "\n";
    return 0;
    }
    1. Odd
      Even
      Odd
      Even
    2. Odd
      Even
      Even
      Odd
    3. Odd
      Odd
      Even
      Even
    4. Even
      Even
      Odd
      Odd
    5. Even
      Odd
      Even
      Odd
Correct Option: A

Running the program will show above behaviour because we have given the value in for loop as 4 instead of 3.



Your comments will be displayed only after manual approval.