Free Online C++ Institute CPP-22-02 Practice Test

Prepare Your C++ Institute CPP-22-02 Exam Questions with Free online CPP-22-02 Practice Test. Get Brilliant CPP - C++ Certified Professional Programmer Exam Results with Valid CPP 22 02 Exam Dumps.

Page:    1 / 46      
Total 230 Questions | Updated On: May 16, 2024
Add To Cart
Question 1

What happens when you attempt to compile and run the following code?
 #include <deque>
 #include <iostream>
 #include <algorithm>
 using namespace std;
 template<class T>struct Out {
 ostream & out;
 Out(ostream & o): out(o){}
 void operator() (const T & val ) { out<<val<<" "; } };
 int main() {
 int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};
 deque<int> d1(t, t+10);
 sort(d1.begin(), d1.end());
 deque<int>::iterator it = upper_bound(d1.begin(), d1.end(), 4);
 for_each(it, d1.end(), Out<int>(cout));cout<<endl;
 return 0;
}
Program outputs:


Answer: A
Question 2

What will happen when you attempt to compile and run the code below, assuming that you
 enter the following sequence: 1 2 3 end<enter>?
 #include <iostream>
 #include <string>
 #include <list>
 #include <algorithm>
 using namespace std;
 template<class T>struct Out {
 ostream & out;
 Out(ostream & o): out(o){}
 void operator() (const T & val ) {out<<val<<" "; } };
 int main ()
 {
 list<int> l;
 for( ; !cin.bad() ; )
 {
 int i;
 cin>>i;
 l.push_back(i);
 }
 for_each(l.begin(), l.end(), Out<int>(cout));
 return 0;
}
Program will output:


Answer: A
Question 3

What will happen when you attempt to compile and run the following code?
 #include <iostream>
 #include <string>
 using namespace std;
 template <class T>
 class A {
 T_v;
 public:
 A() {}
 A(T v): _v(v){}
 T getV() { return _v; }
 void add(T & a) { _v+=a; }
 };
 int main()
 {
 A<string>a("Hello"); string s(" world!");
 a.add(s);
 cout << a.getV() <<endl;
 return 0;
 }


Answer: A
Question 4

What happens when you attempt to compile and run the following code?
 #include <list>
 #include <iostream>
 using namespace std;
 template<class T>
 void print(T start, T end) {
 while (start != end) {
 std::cout << *start << " "; start++;
 }
 }
 int main()
 {
 int t1[] ={ 1, 7, 8, 4, 5 };
 list<int> l1(t1, t1 + 5);
 int t2[] ={ 3, 2, 6, 9, 0 };
 list<int> l2(t2, t2 + 5);
 l1.sort();
 list<int>::iterator it = l2.begin();
 it++; it++;
l1.splice(l1.end(),l2, it, l2.end());
 print(l1.begin(), l1.end()); cout<<"Size:"<<l1.size()<<" ";
 print(l2.begin(), l2.end()); cout<<"Size:"<<l2.size()<<endl;
 return 0;
 }


Answer: A
Question 5

What happens when you attempt to compile and run the following code?
#include <iostream>
 #include <map>
 #include <vector>
 #include <sstream>
 #include <string>
 using namespace std;
 int main(){
 int t[] ={ 3, 4, 2, 1, 0, 1, 2, 3, 4, 0 };
 vector<int> v(t, t+10);
 multimap<int,string> m;
 for(vector<int>::iterator i=v.begin(); i!=v.end(); i++) {
 stringstream s; s<<*i<<*i; m.insert(pair<int,string>(*i,s.str()));
 }
 for(multimap<int, string>::iterator i=m.begin();i!= m.end(); i++) {
 cout<<*i<<" ";
 }
 return 0;
 } 


Answer: A
Page:    1 / 46      
Total 230 Questions | Updated On: May 16, 2024
Add To Cart

© Copyrights DumpsCertify 2024. All Rights Reserved

We use cookies to ensure your best experience. So we hope you are happy to receive all cookies on the DumpsCertify.