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 103 Discussion

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

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

#include

#include

#include

using namespace std;

int main() {

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

map m;

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

m[i]=t[i];

}

map::iterator it = find(m.begin(), m.end(), 5);

cout<first;

return 0;

}

Program outputs:

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Launa
6 days ago
The code will result in a compilation error. The `find()` function in the `map` container is used to search for a key, not a value.
upvoted 0 times
...
Billy
8 days ago
I also think it's D) compilation error, because find() function requires a specific key to search for in a map.
upvoted 0 times
...
Stevie
9 days ago
I agree with Santos, because the find() function cannot be used with map containers.
upvoted 0 times
...
Santos
14 days ago
I think the answer is D) compilation error.
upvoted 0 times
...

Save Cancel