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 4 Question 41 Discussion

Posted by Stephaine on May 08, 2022 at 08:54 PM

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

#include

#include

#include

using namespace std;

int main(){

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

listv(t, t+10);

multiset s1(v.begin(),v.end());

if (s1.count(3) == 2) {

s1.erase(3);

}

for(multiset::iterator i=s1.begin();i!= s1.end(); i++) {

cout<<*i<<" ";

}

return 0;

}

Suggested Answer: D

Get Premium CPP Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
7 comments · newest first
MA
Maryrose 11 months ago
I’m surprised it keeps duplicates in the output!
WI
Winifred 12 months ago
Definitely not a compilation error, that's for sure!
ER
Ernie 12 months ago
Wait, how does it not output 3?
AR
Aretha 12 months ago
I think it should be option B, right?
LA
Lawrence 1 year ago
The program outputs: 1 1 2 2 4 4 5 5
SU
Sue 1 year ago
Okay, I've got this. Ip network planning and design services definitely include customer-based simulation, so the statement is true. The wording is a bit odd, but I'm confident in my answer.
CA
Catrice 1 year ago
I'm pretty sure the answer is option D, 'foo | tee /tmp/foodata'. That will display the output and also write it to the file.
0/2000 characters

Save Cancel