Question
#include <vector>
#include <algorithm>
#include <iostream>
#include <iterator>
using namespace std;
int square(int i) { return i * i; }
int main()
{
vector<int> V, V2;
V.push_back(0);
V.push_back(1);
V.push_back(2);
transform(V.begin(), V.end(), back_inserter(V2), square);
copy(V2.begin(), V2.end(), ostream_iterator<int>(cout, " "));
cout << endl;
}
a.
0
b.
1
c.
2
d.
0 1 4
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. What is the name of the container which contains group of multiple objects?
View solution
Q. How many types of container classes are there in c++?
View solution
Q. What is the use of the allocater interface in the user-defined container?
View solution
Q. How many iterators are needed for the defining a new container?
View solution
Q. What are the design requirements for building a container from the sratch?
View solution
Q. What is mandatory for designing a new container?
View solution
Q. What do we return if we use simple array on a internal container?
View solution
Q. What do all STL containers define?
View solution
Q. What is the lifetime of the element in container?
View solution
Q. Which are not full container classes in c++?
View solution
Q. Where does the vector add the item?
View solution
Q. What type of access does deque and vector provide?
View solution
Q. What type of class template is list?
View solution
Q. To what type of object does the container can be instantiated?
View solution
Q. What kind of library is Standard Template Library?
View solution
Q. What do maps and sets support?
View solution
Q. How many instance are allowed by map and set while inserting a element into container?
View solution
Q. How many items are presented in the associate container?
View solution
Q. By using which of the following the elements in the associate container can
View solution
Q. What do associate containers implement?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!