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 4 Question 44 Discussion

What happens when you attempt to compile and run the following code?#include #include #include #include #include using namespace std;int main(){deque mydeck;list mylist; vector myvector;stack first;stack second(mydeck);stack third(second);stack fourth(mylist);fourth.push(10);fourth.push(11);fourth.push(12);stack fifth(myvector);fifth.push(10);fifth.push(11);fifth.push(12);while(!fifth.empty()){cout
B) compilation error
A) program outputs: 12 11 10 12 11 10
C) program outputs: 10 11 12 10 11 12
D) runtime exception

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

Actual exam question for C++ Institute's CPP exam
Question #: 44
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()

{

deque mydeck;list mylist; vector myvector;

stack first;

stack second(mydeck);

stack third(second);

stack > fourth(mylist);

fourth.push(10);fourth.push(11);fourth.push(12);

stack > fifth(myvector);

fifth.push(10);fifth.push(11);fifth.push(12);

while(!fifth.empty())

{

cout<

fifth.pop();

}

while (!fourth.empty())

{

cout << fourth.front() << " ";

fourth.pop();

}

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Bethanie
7 months ago
Not sure about that output, seems off to me.
upvoted 0 times
...
Margo
7 months ago
Wait, can you really use a list for a stack?
upvoted 0 times
...
Jesusita
7 months ago
Definitely outputs 12 11 10 first, right?
upvoted 0 times
...
Freida
8 months ago
I think there's a compilation error with the stacks.
upvoted 0 times
...
Dorothy
8 months ago
Looks like it should compile fine.
upvoted 0 times
...
Gregoria
8 months ago
Hmm, I'm not totally sure about this one. The prompt says "Switch(config-if>#", so I'm wondering if maybe "end" or "disable" could also work to get out of the interface configuration context.
upvoted 0 times
...
Eric
8 months ago
Wait, is option C really false? I thought informed consent had to include those aspects to protect the facility.
upvoted 0 times
...
Sylvia
8 months ago
I remember learning about this in class, but the wording of the question is throwing me off a bit. I'll have to read through the options closely.
upvoted 0 times
...
Thora
8 months ago
I'm pretty sure the SSAA maintenance takes place in Phase 4, but I'll double-check the material just to be sure.
upvoted 0 times
...

Save Cancel