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

Posted by Xuan on May 03, 2022 at 06:23 PM

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

#include

#include

#include

#include

using namespace std;

void myfunction(int i) {

cout << " " << i;

}

int main() {

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

vector v1(t, t+10);

set s1(t, t+10);

replace(v1.begin(), v1.end(), 1, 10);

replace(s1.begin(), s1.end(), 1, 10);

for_each(v1.begin(), v1.end(), myfunction);

return 0;

}

Program outputs:

Suggested Answer: C

Get Premium CPP Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
8 comments · newest first
LA
Latanya 11 months ago
Definitely B, right?
FR
France 12 months ago
I’m pretty sure it’ll print 10 for the vector but not for the set.
GA
Gabriele 12 months ago
Wait, does the set really ignore duplicates?
RY
Ryan 12 months ago
I think the output should be D.
SU
Sue 1 year ago
The set won't change, so it still has 1.
WI
Wilda 1 year ago
I think I know this one - a service template would be used to apply the same configuration to multiple CPEs, like option B. That seems like a common use case.
MI
Ming 1 year ago
I'm pretty confident I know the answer to this one. HDFEC is simpler and faster than SDEFC, so option A is the false statement. I'll mark that one.
SA
Sarah 1 year ago
I'm pretty sure the no-arbitrage condition plays a key role in these problems. I just wish I could recall the exact formula we used for pricing these Treasury bond forwards.
0/2000 characters

Save Cancel