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 6 Question 82 Discussion

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

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

#include

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) { out<

int main() {

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

deque d1(t, t+10);

set s1(t,t+10);

cout<

return 0;

}

Choose all possible outputs (all that apply):

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Rima
18 days ago
This question is like a game of 'Hide and Seek' with the number 4. Will it be found in the set? Will it be lost in the deque? The suspense is killing me!
upvoted 0 times
...
Vicki
23 days ago
Oh, I've got this! The output will be '1 0', because the `binary_search` function will work for the sorted set, but not for the unsorted deque. This is like trying to find a needle in a haystack... or a 4 in a deque of numbers.
upvoted 0 times
Tammara
3 days ago
User1
upvoted 0 times
...
...
Doretha
25 days ago
This is a tricky one! I think the output will be '0 0', because the `binary_search` function will return 0 for both the set and the deque, as the value 4 is not present in the unsorted deque.
upvoted 0 times
Jolene
18 days ago
I think the output will be '0 0'.
upvoted 0 times
...
...
Rikki
1 months ago
Hmm, I'm not sure about this one. Let me think... Aha! The output should be '1 1', because the `binary_search` function will return 1 for both the set and the deque, since the value 4 is present in both data structures.
upvoted 0 times
I believe it will be '0 1'.
upvoted 0 times
...
Shanda
13 days ago
I think the output will be '0 0'.
upvoted 0 times
...
...
Cyril
2 months ago
I believe the correct answer is A) 0 0 because binary_search will return false for both sets and deques.
upvoted 0 times
...
Frederick
2 months ago
The code should compile and run without any issues. The output should be '1 0', since the `binary_search` function will return 1 for the set and 0 for the deque, as the set is sorted and the deque is not.
upvoted 0 times
Coral
15 days ago
User 2
upvoted 0 times
...
Nada
27 days ago
User 1
upvoted 0 times
...
...
Karl
2 months ago
I agree with Jerry. Sets are not sorted, so binary_search won't work on them.
upvoted 0 times
...
Jerry
2 months ago
I think the output will be A) 0 0 because binary_search does not work on sets.
upvoted 0 times
...

Save Cancel