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 5 Question 106 Discussion

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

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

#include

#include

#include

using namespace std;

class A {

int a;

public:

A(int a) : a(a) {}

int getA() const { return a; } void setA(int a) { this?>a = a; }

};

int main () {

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

deque d (t,t+15);

int number = count(d.begin(), d.end(), 2);

cout<< number<

return 0;

}

Program outputs:

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

Adelle
19 hours ago
Wait, wait, wait... why is there a class A in the code? Is that just a red herring or is it somehow relevant? Ah, who cares, I'll just go with the most straightforward answer, which is B.
upvoted 0 times
...
Wava
15 days ago
Oh, that makes sense. I see your point now.
upvoted 0 times
...
Ira
16 days ago
I disagree, I believe the answer is A) 4 because there are 4 occurrences of the number 2 in the deque
upvoted 0 times
...
Cornell
18 days ago
Hmm, this looks like a simple problem of counting occurrences of a number in a container. I'll go with option B, since 2 appears 3 times in the given array.
upvoted 0 times
...
Wava
23 days ago
I think the answer is B) 3
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77