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[] = {-12, -41, -15, -20, -10};
    transform ( num, num + 2, num, negate<int>() );
    for (int k = 0; k < 5; ++k)
    cout << num[k] << " ";
    }
    1. 12
    2. 12 41
    3. 12 41 -15
    4. 12 41 -15 -20
    5. 12 41 -15 -20 -10
Correct Option: E

In this program, We negated the given value by using the functional objects, So it is producing this output.



Your comments will be displayed only after manual approval.