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 Exam CPP Topic 7 Question 89 Discussion

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

What happens 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, 6, 5, 7, 9, 8, 0 };

vector v(t, t+10);

map m;

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

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

}

for(map::iterator i=m.begin();i!= m.end(); i++) {

cout<<*i<<" ";

}

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

Carmen
3 days ago
Hmm, this looks like a classic C++ question. I'll have to think through the logic carefully.
upvoted 0 times
...
Janet
5 days ago
I think the program will output 6.
upvoted 0 times
...

Save Cancel