C++ Institute C++ Certified Professional Programmer CPP Question # 9 Topic 1 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 9 Topic 1 Discussion

CPP Exam Topic 1 Question 9 Discussion:
Question #: 9
Topic #: 1

What will happen when you attempt to compile and run the following code?

#include

#include

#include

#include

#include

using namespace std;

int main() {

int t[] = { 3, 4, 2, 1, 0, 3, 4, 1, 2, 0 };

vector v(t, t + 10);

multimap m;

for (vector::iterator i = v.begin(); i != v.end(); i++) {

stringstream s;s << *i << *i;

m.insert(pair(*i, s.str()));

}

pair::iterator, multimap::iterator> range;

range = m.equal_range(2);

for (multimap::iterator i = range.first; i != range.second; i++) {

cout << i?>first << " ";

}

return 0;

}

The output will be:


A.

2 2


B.

1 2


C.

1 3


D.

2


E.

0 2


Get Premium CPP Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.