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:

Wava
4 days ago
Oh, that makes sense. I see your point now.
upvoted 0 times
...
Ira
5 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
7 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
12 days ago
I think the answer is B) 3
upvoted 0 times
...

Save Cancel