GrabCert
HomeExamsProvidersAbout
Sign InSign Up
Home/Exams/C++ Institute C++ Certified Professional Programmer/Question #13
#13Multiple Choice

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
using namespace std;

void myfunction(int i) {
cout << " " << i;
}

int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector<int> v1(t, t + 10);
deque<int> d1(t, t + 10);
set<int> s1(t, t + 10);

for_each(v1.begin(), v1.end(), myfunction); // Line I

for_each(d1.begin(), d1.end(), myfunction); // Line II

for_each(s1.begin(), s1.end(), myfunction); // Line III
return 0;
}

Previous
Question 13 of 228
Exam CPP Topic 1 Question 13
Back to all questions
Next
GrabCert

Your trusted source for certification exam preparation. Pass your exams with confidence.

Quick Links

  • Home
  • Exams
  • Providers

Legal

  • About
  • Contact Us
  • Refund Policy
  • Privacy Policy
  • Terms of Service

© 2026 GrabCert. All rights reserved.

Sign InSign Up