What happens when you attempt to compile and run the following code? #include <deque> #include <iostream> #include <algorithm> #include <set> using namespace std; template<class T>struct Out { ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out<<val<<" "; } }; bool Compare(char a, char b) { return tolower(a) < tolower(b);} int main() { char s[]={"qwerty"}; char t1[]={"ert"}; char t2[]={"ERT"}; sort(s, s+6); cout<<includes(s,s+6, t1,t1+3, Compare)<<" "<<includes(s,s+6, t2,t2+3, Compare)<<endl; return 0; }Program outputs:
Answer(s): D
What happens when you attempt to compile and run the following code? #include <vector> using namespace std; int main () { std::vector<int> v1; v1.push_back(10); return 0; }
What will happen when you attempt to compile and run the following code? #include <iostream> #include <set> #include <vector> using namespace std; int main(){ int t[] = { 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 }; vector<int> v(t, t+10); set<int> s1(v.begin(),v.end()); s1.insert(v.begin(),v.end()); bool found = s1.find(7); if (found){ cout<<"Element found!\n"; }else { cout<<"Element not found!\n"; } return 0; }
Answer(s): C
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; } bool classifier(int v) { return v%2==0; } int main() { int t[] = { 1, 5, 2, 5, 2, 4, 4, 3, 3, 1 }; vector<int> v1(t, t+10); set<int> s1(t, t+10); replace(v1.begin(), v1.end(),classifier, 10); for_each(v1.begin(), v1.end(), myfunction); return 0; }Program outputs:
What happens when you attempt to compile and run the following code? #include <deque> #include <list> #include <iostream> using namespace std; int main () { list<int> l1; deque<int> d1; for(int i=0; i<5; i++) { l1.push_back(i);l1.push_front(i); d1.push_back(i);d1.push_front(i); } for(int i=0; i<d1.size(); i++) { cout<<d1[i]<<" "<<l1[i]<<" "; } cout<<endl; return 0; }
Answer(s): E
Post your Comments and Discuss C++ Institute CPP exam prep with other Community members: