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:

Gretchen
2 months ago
Wait, is this a trick question? I'm going to go with A. The program should output the original array of integers in their string form 'zero one two three four five six seven eight nine'.
upvoted 0 times
...
Bette
2 months ago
Haha, I'm feeling lucky. I think the answer is E. The program will just output the original array of integers '0 1 2 3 4 5 6 7 8 9' without any string conversions.
upvoted 0 times
Shawnda
10 days ago
User3
upvoted 0 times
...
Lindsey
11 days ago
User2
upvoted 0 times
...
Tricia
15 days ago
User1
upvoted 0 times
...
...
Stefanie
2 months ago
This is a tricky one, but I'm betting on D. The program will output 'ten eleven two three four five six seven eight nine' because the 0th element was changed to 'ten' and a new element with key 1 was inserted as 'eleven'.
upvoted 0 times
...
Pok
2 months ago
I'm going with C. The program will output 'zero eleven two three four five six seven eight nine' since the 0th element was changed to 'ten' and a new element with key 1 was inserted as 'eleven'.
upvoted 0 times
Cecily
19 days ago
Yes, the output will be 'zero eleven two three four five six seven eight nine'.
upvoted 0 times
...
Cecily
1 months ago
I agree, the program will output 'zero eleven two three four five six seven eight nine'.
upvoted 0 times
...
Cecily
2 months ago
I think it will output 'zero eleven two three four five six seven eight nine'.
upvoted 0 times
...
...
Annelle
2 months ago
I'm not sure, but I think the correct answer is A) program outputs: zero one two three four five six seven eight nine.
upvoted 0 times
...
Barney
2 months ago
I believe the program will output: ten one two three four five six seven eight nine.
upvoted 0 times
...
Annelle
2 months ago
I think the program will output: zero one two three four five six seven eight nine.
upvoted 0 times
...
Marquetta
3 months 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
Sharen
30 days ago
Actually, the correct answer is D. It will output 'ten eleven two three four five six seven eight nine'.
upvoted 0 times
...
Katlyn
1 months ago
No, I think it will output 'zero one two three four five six seven eight nine'.
upvoted 0 times
...
Azzie
1 months ago
I believe the program will output 'ten one two three four five six seven eight nine'.
upvoted 0 times
...
Vivan
1 months ago
I think the answer is B.
upvoted 0 times
...
Dewitt
1 months ago
Great, so the correct answer is B.
upvoted 0 times
...
Lemuel
2 months ago
That's correct, the value of the 0th element in the map was modified to 'ten'.
upvoted 0 times
...
Emerson
2 months ago
Yes, the program should output 'ten one two three four five six seven eight nine'.
upvoted 0 times
...
Jamal
2 months ago
I think the answer is B.
upvoted 0 times
...
...

Save Cancel