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 CPP Exam - Topic 1 Question 20 Discussion

What happens when you attempt to compile and run the following code?#include #include using namespace std;int main() {int t[] = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"};multimap m;for (int i = 0; i < 10; i++) {m.push_back(pair(t[i], s[i]));}for (multimap::iterator i = m.begin(); i != m.end(); i++) {cout first
B) compilation error
A) program outputs: 1 2 3 4 5
C) program outputs: 1 1 2 2 3 3 4 4 5 5
D) program outputs: one two three four five
E) program outputs: one one two two three three four four five five

C++ Institute CPP Exam - Topic 1 Question 20 Discussion

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

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

#include

#include

using namespace std;

int main() {

int t[] = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };

string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"};

multimap m;

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

m.push_back(pair(t[i], s[i]));

}

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

cout << i?>first << " ";

}

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Ashton
9 months ago
Nah, it should just print the unique keys.
upvoted 0 times
...
Tarra
9 months ago
Wait, really? I thought it would show all the pairs!
upvoted 0 times
...
Bonita
9 months ago
I think it will output 1 2 3 4 5.
upvoted 0 times
...
Blythe
9 months ago
Totally agree, that’s not a valid method for multimaps.
upvoted 0 times
...
Tyisha
9 months ago
Looks like a compilation error due to push_back.
upvoted 0 times
...
Pamella
10 months ago
Okay, I think I've got this. The key is to use a virtual network with a single subnet and a standard Azure load balancer. That way, the VMs will be able to fail over quickly and maintain existing connections. Option B looks like the way to go here.
upvoted 0 times
...
Lashanda
10 months ago
Easy peasy! The question states the website is hosted on EC2 instances behind an Application Load Balancer, so the answer has to be B. We use an A record to point the zone apex to the IP address of the load balancer.
upvoted 0 times
...

Save Cancel