-
What is the output of this program?
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
int op_increase (int k)
{
return ++k;
}
int main ()
{
vector<int> p;
vector<int> q;
for (int k = 0; k < 5; k++)
p.push_back (k * 12);
q.resize(p.size());
transform (p.begin(), p.end(), q.begin(), op_increase);
transform (p.begin(), p.end(), q.begin(), p.begin(), plus<int>());
for (vector<int> :: iterator Iter = p.begin(); Iter != p.end(); ++Iter)
cout << ' ' << *Iter;
return 0;
}
-
- 1 25
- 1 25 49
- 1 25 49 73
- 1 25 49 73 97
- Compilation Error
Correct Option: D
In this program, We allocated the values to the vector and then by using transform function, We increased the values.