Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPP Exam - Topic 7 Question 128 Discussion

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
A) 2 2
B) 1 2
C) 1 3
D) 2
E) 0 2

C++ Institute CPP Exam - Topic 7 Question 128 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 128
Topic #: 7
[All CPP Questions]

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:

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

0/2000 characters

Currently there are no comments in this discussion, be the first to comment!


Save Cancel