BlackFriday 2024! 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 9 Question 96 Discussion

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

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

#include

#include

#include

using namespace std;

int main(){

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

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

multimap m;

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

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

}

if (m[11] == "eleven") {

cout<<"eleven ";

}

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

cout<second<<" ";

}

cout<

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

Pamella
19 days ago
This code is so complicated, I'm just going to guess. I'll go with A. The program outputs one two three four five six seven eight nine ten 11, because that's the most random-sounding answer. Hey, at least I'm honest about my guessing!
upvoted 0 times
Irene
8 days ago
Guessing is not a good idea when it comes to coding.
upvoted 0 times
...
...
France
22 days ago
This is a tricky one, but I think the answer is E. The program will throw a compilation error because the code is trying to access the multimap with an index of 11, which is not a valid key in the multimap.
upvoted 0 times
...
Ona
25 days ago
Hmm, I'm not sure about this one. I'm going to go with C. The program outputs one two three four five six seven eight nine ten 10, because that's what it looks like the code is doing.
upvoted 0 times
Mitzie
5 days ago
I'm not sure either, but I think it might be A. The program outputs one two three four five six seven eight nine ten 11.
upvoted 0 times
...
Frankie
6 days ago
No, I disagree. It's definitely B. The program outputs one two three four five six seven eight nine ten 10.
upvoted 0 times
...
Vicente
14 days ago
I think it's actually D. The program outputs eleven one two three four five six seven eight nine ten 10.
upvoted 0 times
...
...
Rebecka
1 months ago
I think the answer is D. The program will output eleven one two three four five six seven eight nine ten 10, because the if statement checks for the value 11 in the multimap, which will be true and print 'eleven'.
upvoted 0 times
Nell
21 days ago
Oh, I see. Thanks for clarifying.
upvoted 0 times
...
Lourdes
1 months ago
No, the correct answer is B.
upvoted 0 times
...
Hubert
1 months ago
I think the answer is D.
upvoted 0 times
...
...
Glynda
2 months ago
I'm not sure, but I think the program will compile without errors and output one two three four five six seven eight nine ten 10.
upvoted 0 times
...
Maricela
2 months ago
I agree with Filiberto, the program should output one two three four five six seven eight nine ten 10.
upvoted 0 times
...
Vallie
2 months ago
The correct answer is B. The program will output one two three four five six seven eight nine ten 10, as the multimap will contain the values from 1 to 10, and the size of the multimap will be 10.
upvoted 0 times
Sang
14 days ago
D) program outputs: eleven one two three four five six seven eight nine ten 10
upvoted 0 times
...
Santos
1 months ago
C) program outputs: one two three four five six seven eight nine ten 10
upvoted 0 times
...
Elsa
1 months ago
B) program outputs: one two three four five six seven eight nine ten 10
upvoted 0 times
...
Lashonda
1 months ago
A) program outputs: one two three four five six seven eight nine ten 11
upvoted 0 times
...
...
Filiberto
2 months ago
I think the correct answer is B.
upvoted 0 times
...

Save Cancel