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 Exam CPP Topic 7 Question 108 Discussion

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

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

#include

#include

#include

using namespace std;

int main ()

{

int t[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

vector v1(t, t + 10);

deque d1(v1.begin(), v1.end());

deque d2;

d2 = d1;

d2.insert(d1.rbegin(), 10);

for(int i = 0; i

{

cout<

}

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Mattie
9 days ago
I believe there might be a compilation error due to incorrect usage of insert function
upvoted 0 times
...
Lizbeth
20 days ago
I'm not sure, but I think the program will output: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
Hobert
24 days ago
I agree with Casie, because the code inserts 10 at the beginning of d1
upvoted 0 times
...
Dannie
24 days ago
Haha, this question is like a deque of trouble! I'll say option D, compilation error. Who knows what kind of shenanigans the compiler might pull with all these containers and iterators?
upvoted 0 times
...
Patria
28 days ago
I'm a bit unsure about this one. I'll go with option A, the program outputs 0 1 2 3 4 5 6 7 8 9 10. Inserting an element at the end of the deque seems like the straightforward approach.
upvoted 0 times
...
Casie
30 days ago
I think the program will output: 0 1 2 3 4 5 6 7 8 9 10
upvoted 0 times
...
Freida
1 months ago
Hmm, this seems like a tricky one. I'm going to go with option B, the program outputs 10 0 1 2 3 4 5 6 7 8 9. Inserting an element at the end of the deque using the reverse iterator makes sense to me.
upvoted 0 times
Karan
11 days ago
I agree with option C, the program outputs: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
Fausto
21 days ago
I believe it's option C, the program outputs: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
Bea
22 days ago
I think the program outputs: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
...

Save Cancel
a