Last Updated on June 24, 2022 by Admin
What will happen when you attempt to compile and run the following code?
#include <iostream> #include <algorithm> #include <vector> #include <deque> #include <set> using namespace std; int main() { int mynumbers[] = { 3, 9, 0, 2, 1, 4, 5 }; vector < int > v1 (mynumbers, mynumbers + 7); deque < int > d1 (mynumbers, mynumbers + 7); set < int > s1 (mynumbers, mynumbers + 7); vector < int >::iterator found = find (v1.begin (), v1.end (), 3); //LINE I if (found != v1.end ()) //LINE II cout << "found" << ", "; cout << find (d1.begin (), d1.end (), 9) << ", "; //LINE III cout << find (s1.begin (), s1.end (), 6); //LINE IV return 0; }
- compilation error in LINE II
- compilation error in LINE III
- the program outputs
3, 9, 6
- the program outputs
found, 9, 6
- compilation error in LINE IV
- the exception will be thrown at LINE I
- compilation error in LINE I
- the program outputs
found, 9,