C++ Institute C++ Certified Professional Programmer CPP Question # 11 Topic 2 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 11 Topic 2 Discussion

CPP Exam Topic 2 Question 11 Discussion:
Question #: 11
Topic #: 2

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

#include

#include

using namespace std;

int main() {

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

string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"};

map m;

for (int i = 0; i < 10; i++) {

m.push_back(pair(t[i], s[i]));

}

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

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

}

return 0;

}


A.

program outputs: 1 2 3 4 5


B.

compilation error


C.

program outputs: 1 1 2 2 3 3 4 4 5 5


D.

program outputs: one two three four five


E.

program outputs: one one two two three three four four five five


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.