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

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
#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 };
set<int> s1(t, t+10);
vector<int> v1(s1.rbegin(), s1.rend());
swap_ranges(s1.begin(), s1.end(), v1.begin());
for_each(v1.begin(), v1.end(), myfunction);
for_each(s1.begin(), s1.end(), myfunction);
return 0;
}
Program outputs:

Previous
Question 15 of 228
Exam CPP Topic 1 Question 15
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