What happens when you attempt to compile and run the following code? #include <deque> #include <vector> #include <iostream> using namespace std; int main () { int t[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; vector<int> v1(t, t + 10); deque<int> d1(v1.begin(), v1.end()); deque<int> d2; d2 = d1; d2.insert(d1.rbegin(), 10); for(int i = 0; i<d1.size(); i++) { cout<<d1[i]<<" "; } return 0; }
Answer(s): D
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { cout<<100<<" "; cout.setf(ios::hex); cout<<100<<" "; return 0; } Program outputs:
Answer(s): E
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { cout.setf(ios::hex, ios::basefield); cout<<100<<" "; cout.flags(ios::showbase); cout<<100<<" "; return 0; } Program outputs:
What happens when you attempt to compile and run the following code? #include <iostream> #include <algorithm> #include <vector> using namespace std; int main () { int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5}; vector<int> v (t,t+15); vector<int>::iterator it = search_n(v.begin(), v.end(), 4, 2); cout<< it?v.begin()<<endl; return 0; }Program outputs:
What happens when you attempt to compile and run the following code? #include <deque> #include <vector> #include <iostream> #include <string> using namespace std; template<typename T> void print(T start, T end) { while (start != end) cout<<*start++; } int main () { string t[] = {"one", "two" ,"three" ,"four", "five"}; vector<string> v1(t, t+5); deque<string> d1(v1.rbegin(), v1.rend()); d1.push_back("zero"); print(d1[0].rbegin(),d1[0].rend()); return 0; }
Answer(s): B
Post your Comments and Discuss C++ Institute CPP exam prep with other Community members: