New Year Sale 2026! 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

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

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:

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

0/2000 characters
Latanya
4 months ago
Definitely B, right?
upvoted 0 times
...
France
4 months ago
I’m pretty sure it’ll print 10 for the vector but not for the set.
upvoted 0 times
...
Gabriele
4 months ago
Wait, does the set really ignore duplicates?
upvoted 0 times
...
Ryan
4 months ago
I think the output should be D.
upvoted 0 times
...
Sue
5 months ago
The set won't change, so it still has 1.
upvoted 0 times
...
Wilda
5 months 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.
upvoted 0 times
...
Ming
5 months 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.
upvoted 0 times
...
Sarah
5 months 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.
upvoted 0 times
...

Save Cancel