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

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

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:

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

0/2000 characters
Noble
4 months ago
I’m surprised it doesn’t compile at all!
upvoted 0 times
...
Theodora
4 months ago
The output should be D for sure.
upvoted 0 times
...
Myrtie
4 months ago
Wait, really? I thought sets could add elements like vectors.
upvoted 0 times
...
Delfina
4 months ago
Totally agree, sets don’t have push_back!
upvoted 0 times
...
Sherly
4 months ago
Looks like a compilation error due to push_back on set.
upvoted 0 times
...
Marylin
5 months ago
I’m not sure, but I feel like the output could be unpredictable because of the set. Maybe option C?
upvoted 0 times
...
Janey
5 months 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.
upvoted 0 times
...
Renea
5 months ago
I think the loop condition `i??` is definitely wrong, which might lead to a compilation error.
upvoted 0 times
...
Tony
5 months ago
I remember something about the `push_back` method, but I thought it was only for vectors, not sets.
upvoted 0 times
...
Keva
5 months 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.
upvoted 0 times
...
Steffanie
5 months ago
Okay, let's see... I'm pretty sure the answer is not A or D, so I'll focus on B and C.
upvoted 0 times
...
Jesse
5 months 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.
upvoted 0 times
...

Save Cancel