ExamVeda
Login
Home
C plus plus miscellaneous
?

What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
int op_increase (int i)
{
    return ++i;
}
int main ()
{
    vector<int> a;
    vector<int> b;
    for (int i = 1; i < 4; i++)
    a.push_back (i * 10);
    b.resize(a.size());
    transform (a.begin(), a.end(), b.begin(), op_increase);
    transform (a.begin(), a.end(), b.begin(), a.begin(), plus<int>());
    for (vector<int> :: iterator it = a.begin(); it != a.end(); ++it)
        cout << ' ' << *it;
    return 0;
}

Answer & Solution
Correct Answer: Option D
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.