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
22 days ago
I believe there might be a compilation error due to incorrect usage of insert function
upvoted 0 times
...
Lizbeth
1 months 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
1 months ago
I agree with Casie, because the code inserts 10 at the beginning of d1
upvoted 0 times
...
Dannie
1 months 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
Miss
5 days ago
I agree, the correct answer is C) program outputs: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
Rene
13 days ago
I think it will output: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
...
Patria
1 months 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
1 months 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
24 days ago
I agree with option C, the program outputs: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
Fausto
1 months ago
I believe it's option C, the program outputs: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
Bea
1 months ago
I think the program outputs: 0 1 2 3 4 5 6 7 8 9
upvoted 0 times
...
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77