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 60 Discussion

Posted by Gilma on Dec 24, 2022 at 05:39 PM

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

#include

#include

#include

using namespace std;

template void print(T start, T end) {

while (start != end) {

std::cout << *start << " "; start++;

}

}

int main(){

vectorv;

set s;

for(int i=10; i>0; i??) {

v.push_back(i);

s.push_back(i);

}

print(v.begin(), v.end()); print(s.begin(), s.end());cout<

return 0;

}

The output will be:

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
12 comments · newest first
NO
Noble 11 months ago
I’m surprised it doesn’t compile at all!
TH
Theodora 11 months ago
The output should be D for sure.
MY
Myrtie 12 months ago
Wait, really? I thought sets could add elements like vectors.
DE
Delfina 12 months ago
Totally agree, sets don’t have push_back!
SH
Sherly 12 months ago
Looks like a compilation error due to push_back on set.
MA
Marylin 1 year ago
I’m not sure, but I feel like the output could be unpredictable because of the set. Maybe option C?
JA
Janey 1 year ago
This question seems similar to one we practiced where we had to identify errors in code. I’m leaning towards option D for that reason.
RE
Renea 1 year ago
I think the loop condition `i??` is definitely wrong, which might lead to a compilation error.
TO
Tony 1 year ago
I remember something about the `push_back` method, but I thought it was only for vectors, not sets.
KE
Keva 1 year ago
Hmm, I'm a bit unsure about this one. The prompt talks about competitive and benchmark data, but I'm not totally clear on how that relates to quality leadership. I'll need to think this through carefully.
ST
Steffanie 1 year ago
Okay, let's see... I'm pretty sure the answer is not A or D, so I'll focus on B and C.
JE
Jesse 1 year ago
This reminds me of a practice question where we discussed how prompting and fading help with language acquisition. I feel like it's definitely related to stimulus generalization too, but I might be mixing them up.
0/2000 characters

Save Cancel