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 88 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 88
Topic #: 4
[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<

};

bool Compare(char a, char b) { return tolower(a) < tolower(b);}

int main() {

char s[]={"qwerty"};

char t1[]={"ert"};

char t2[]={"ERT"};

sort(s, s+6);

cout<

return 0;

}

Program outputs:

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

Evangelina
1 months ago
Wait, wait, wait... the 'includes' function is case-sensitive? I thought it was case-insensitive! I guess I need to re-read the C++ documentation more carefully. *facepalm*
upvoted 0 times
...
Magnolia
1 months ago
The output will be 1 0, because the 'includes' function is case-sensitive, and 't1' (ert) is present in the sorted string 's' (eqrty), but 't2' (ERT) is not, since the comparison is case-sensitive.
upvoted 0 times
Rebecka
9 days ago
D) 1 1
upvoted 0 times
...
Marge
10 days ago
C) 1 0
upvoted 0 times
...
Thaddeus
17 days ago
B) 0 1
upvoted 0 times
...
Altha
20 days ago
A) 0 0
upvoted 0 times
...
...
Lizbeth
2 months ago
Hmm, this looks like a tricky one. I'll have to double-check the 'includes' function and the 'Compare' function to be sure, but my guess is that the output will be 0 1.
upvoted 0 times
...
Gerald
2 months ago
I think the output will be 1 1, because the 'includes' function checks if all the elements in the second range are present in the first range, and both 't1' (ert) and 't2' (ERT) are present in the sorted string 's' (eqrty).
upvoted 0 times
Goldie
12 days ago
Oh, I see. Thanks for the explanation.
upvoted 0 times
...
Goldie
20 days ago
No, the output will be 1 0 because 't1' (ert) is present in the sorted string 's' (eqrty) but 't2' (ERT) is not.
upvoted 0 times
...
Goldie
1 months ago
C) 1 0
upvoted 0 times
...
...
Jade
2 months ago
The output of the program will be 0 1, as the 'includes' function checks if all the elements in the second range are present in the first range, and the characters in 't2' (ERT) are all present in the sorted string 's' (eqrty), but the characters in 't1' (ert) are not all present in 's'.
upvoted 0 times
Martina
22 days ago
Characters in 't2' (ERT) are all present in the sorted string 's' (eqrty), but characters in 't1' (ert) are not all present in 's'.
upvoted 0 times
...
Martina
25 days ago
The 'includes' function checks if all elements in the second range are present in the first range.
upvoted 0 times
...
Martina
1 months ago
B) 0 1
upvoted 0 times
...
...
Rickie
3 months ago
Why do you think it's C) 1 0?
upvoted 0 times
...
Skye
3 months ago
I disagree, I believe the correct answer is C) 1 0.
upvoted 0 times
...
Rickie
3 months ago
I think the answer is B) 0 1.
upvoted 0 times
...

Save Cancel