Last Updated on May 22, 2022 by Admin 3
What happen when you attempt to compile and run the following code? Choose all that apply:
#include <vector> #include <iostream> #include <algorithm> using namespace std; void printer(double i) { cout <<i<<", "; } bool compare (double a, double b) { return int (a) < int (b); } int main() { double mynumbers[] = { 1.11, 3.13, 2.12, 5.15, 6.16}; vector <double> v1 (mynumbers, mynumbers + 5); stable_sort (v1.begin(), v1.end(), compare); //LINE I remove (v1.begin(), v1.end(), 5.15); //LINE II for_each(v1.begin(), v1.end(), printer); return 0; }
- size of
v1
vector is5
- the program outputs
1.11, 3.13, 2.12, 6.16,
- compilation error in LINE II
- compilation error in LINE I
- size of
v1
vector is6
- the program outputs
1.11, 3.13, 2.12, 6.16, 6.16,
- the program outputs
1.11, 2.12, 3.13, 6.16, 6.16,