Cyber Monday 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
2 months 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
Marylou
18 days ago
I agree, the program will output one two three four five six seven eight nine ten 10.
upvoted 0 times
...
Mose
19 days ago
I think the correct answer is B, based on the code logic.
upvoted 0 times
...
Kaitlyn
25 days ago
True, it's always better to understand the code first.
upvoted 0 times
...
Irene
1 months ago
Guessing is not a good idea when it comes to coding.
upvoted 0 times
...
...
France
2 months 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
2 months 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
1 months 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
1 months 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
1 months 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
2 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
2 months ago
Oh, I see. Thanks for clarifying.
upvoted 0 times
...
Lourdes
2 months ago
No, the correct answer is B.
upvoted 0 times
...
Hubert
2 months ago
I think the answer is D.
upvoted 0 times
...
...
Glynda
3 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
3 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
3 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
1 months ago
D) program outputs: eleven one two three four five six seven eight nine ten 10
upvoted 0 times
...
Santos
2 months ago
C) program outputs: one two three four five six seven eight nine ten 10
upvoted 0 times
...
Elsa
2 months ago
B) program outputs: one two three four five six seven eight nine ten 10
upvoted 0 times
...
Lashonda
2 months ago
A) program outputs: one two three four five six seven eight nine ten 11
upvoted 0 times
...
...
Filiberto
3 months ago
I think the correct answer is B.
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