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 1 Question 107 Discussion

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

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

#include

#include

#include

#include

using namespace std;

int main(){

int second[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };

string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","zero"};

map m;

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

m.insert(pair(second[i],first[i]));

}

m[0]="ten";

m.insert(pair(1,"eleven"));

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

cout<second<<" ";

}

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Barney
2 days ago
I believe the program will output: ten one two three four five six seven eight nine.
upvoted 0 times
...
Annelle
4 days ago
I think the program will output: zero one two three four five six seven eight nine.
upvoted 0 times
...
Marquetta
17 days ago
Hmm, I think the answer is B. The program should output 'ten one two three four five six seven eight nine' after modifying the value of the 0th element in the map.
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