C++ Institute C++ Certified Professional Programmer CPP Question # 64 Topic 7 Discussion

C++ Institute C++ Certified Professional Programmer CPP Question # 64 Topic 7 Discussion

CPP Exam Topic 7 Question 64 Discussion:
Question #: 64
Topic #: 7

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

#include

#include <algorithm>

#include

#include

using namespace std;

void myfunction(int i) {

cout << " " << i;

}

int main() {

vector v1(10,1);

fill(v1.begin()+2, v1.end()?2,2);

fill_n(v1.begin()+4,2,3);

for_each(v1.begin(), v1.end(), myfunction);

return 0;

}

Program outputs:


A.

1 1 2 2 3 3 2 2 1 1


B.

1 1 2 2 2 2 2 2 1 1


C.

compilation error


D.

none of these


Get Premium CPP Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.