U.S. Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPP Exam - Topic 4 Question 122 Discussion

What happens when you attempt to compile and run the following code?#include #include #include #include #include using namespace std;int main(){int t[] ={ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};deque mydeck(t, t+10);list mylist(t,t+10);queue first;queue second(mydeck);queue third(second);queue fourth(mylist);mylist.clear();third.clear();cout
E) compilation error
A) program outputs: 10 0 10 0
B) program outputs: 0 0 0 0
C) program outputs: 10 10 10 10
D) program outputs: 10 0 0 10

C++ Institute CPP Exam - Topic 4 Question 122 Discussion

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

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

#include

#include

#include

#include

#include

using namespace std;

int main()

{

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

deque mydeck(t, t+10);list mylist(t,t+10);

queue first;

queue second(mydeck);

queue third(second);

queue > fourth(mylist);

mylist.clear();third.clear();

cout<

cout<

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

0/2000 characters
Laurene
2 months ago
I practiced a similar question where clearing a container affected the size. I feel like the output might be option A, but I can't recall exactly.
upvoted 0 times
...
Margurite
2 months ago
I remember something about queues and how they manage their size. I think `third.size()` should return 10, but I'm confused about `mylist.size()` after clearing it.
upvoted 0 times
...
Shanda
2 months ago
I think the program should compile fine since all the includes are correct, but I'm not sure about the output.
upvoted 0 times
...

Save Cancel