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
set
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
1 year ago
Definitely B, right?
FR
France
1 year ago
I’m pretty sure it’ll print 10 for the vector but not for the set.
GA
Gabriele
1 year ago
Wait, does the set really ignore duplicates?
RY
Ryan
1 year 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.