New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPP Exam - Topic 4 Question 21 Discussion

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

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

#include

#include

#include

using namespace std;

int main () {

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

vector v (t,t+10);

vector::iterator it;

int m1[] = {1, 3, 2};

it = find_first_of (v.begin(), v.end(), m1, m1+3);

cout << "First found at position: " << it?v.begin() << endl;

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Phuong
4 months ago
The iterator returns the position, so A makes sense.
upvoted 0 times
...
Kristian
4 months ago
Wait, are you sure about that? Seems off to me.
upvoted 0 times
...
Blair
4 months ago
I thought it would be 0, but I guess not.
upvoted 0 times
...
Melinda
4 months ago
Definitely A, that's the correct output!
upvoted 0 times
...
Katlyn
5 months ago
It finds the first occurrence of 1, which is at index 5.
upvoted 0 times
...
Isadora
5 months ago
I feel pretty confident about this. The output should be S 5 based on the way the code is structured.
upvoted 0 times
...
Chantell
5 months ago
I'm leaning towards the Compliance policies tab. That's where we manage all the rules and restrictions for device access, including things like compromised status.
upvoted 0 times
...

Save Cancel