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

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

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

#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);

deque::iterator it = lower_bound(d1.begin(), d1.end(), 4);

for_each(it, d1.end(), Out(cout));cout<

return 0;

}

Program outputs:

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

Shalon
9 days ago
I'm not sure, but I think the answer is A) 1 2 3 4 5 6 7 8 9 10 because lower_bound returns an iterator to the first element that is not less than the value passed, which is 4 in this case.
upvoted 0 times
...
Lewis
9 days ago
I agree with Viola, the lower_bound function returns an iterator to the first element that is not less than the value passed, so the output should be A) 1 2 3 4 5 6 7 8 9 10.
upvoted 0 times
...
Viola
11 days ago
I think the answer is A) 1 2 3 4 5 6 7 8 9 10 because lower_bound finds the first element that is not less than 4 in the deque.
upvoted 0 times
...

Save Cancel