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:

Ozell
19 hours ago
Aha, I know this one! Gotta love those stringstreams and map insertions.
upvoted 0 times
...
Janet
8 days ago
I'm not sure, but I think the program will output 6 7.
upvoted 0 times
...
Celia
10 days ago
I believe the program will output 5 7.
upvoted 0 times
...
Carmen
14 days ago
Hmm, this looks like a classic C++ question. I'll have to think through the logic carefully.
upvoted 0 times
...
Janet
16 days ago
I think the program will output 6.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77