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 7 Question 2 Discussion

Posted by Tamar on May 06, 2022 at 09:23 AM

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);

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

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

s1.erase(3);

}

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

cout<<*i<<" ";

}

return 0;

}

Suggested Answer: A

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
GE
Gerald 11 months ago
No compilation errors here!
AR
Arleen 12 months ago
I thought it would show duplicates!
EL
Ellsworth 12 months ago
Wait, how can count(3) be 2?
CH
Christiane 12 months ago
Definitely outputs 1 2 4 5!
MA
Mabel 1 year ago
The set will only keep unique values.
KI
King 1 year ago
I'm feeling pretty confident about this one. The requirement to run the new version alongside the old version before switching over points directly to a blue/green deployment strategy. Let's go with that.
AN
Anabel 1 year ago
Hmm, this looks like a tricky one. I'll need to carefully read through the error message and the options to figure out the best approach.
0/2000 characters

Save Cancel