Higher Test Marks with Free Online CPP-22-02 Exam Practice

Assess the CertsIQ’s updated CPP-22-02 exam questions for free online practice of your CPP - C++ Certified Professional Programmer test. Our CPP 22 02 dumps questions will enhance your chances of passing the C++ Certified Professional Programmer certification exam with higher marks.

Exam Code: CPP-22-02
Exam Questions: 230
CPP - C++ Certified Professional Programmer
Updated: 24 Nov, 2025
Question 1

What happens when you attempt to compile and run the following code?
 #include <vector>
 #include <iostream>
 #include <algorithm>
 using namespace std;
 template<typename T>class B { T val;
 public:
 B(T v):val(v){}
 T getV() const {return val;} bool operator < (const B & v) const { return val<v.val;} };
 template<class T>ostream & operator <<(ostream & out, const B<T> & v) { out<<v.getV();
return out;}
 template<class T>struct Out {
 ostream & out;
 Out(ostream & o): out(o){}void operator() (const T & val ) { out<<val<<" "; } };
 bool Less(const B<float> &a, const B<float> &b) { return int(a.getV())<int(b.getV());}
 int main() {
 float t[]={2.28, 1.66, 1.32, 3.94, 3.64, 2.3, 2.98, 1.96, 2.62, 1.13};
 vector<B<float> > v1; v1.assign(t, t+10);
 stable_sort(v1.begin(), v1.end(), Less);
 for_each(v1.begin(), v1.end(), Out<B<float> >(cout));cout<<endl;
 return 0;
 }
Program outputs:

Options :
Answer: A

Question 2

What happens when you attempt to compile and run the following code?
 #include <iostream>
 using namespace std;
 template<class A>
 void f(A a)
 {
 cout<<1<<endl;
 }
 void f(int a)
 {
 cout<<2<<endl;
 }
 int main(){
 int a = 1;
 f<float>(a);
 return 0;
 }

Options :
Answer: A

Question 3

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:

Options :
Answer: D

Question 4

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:

Options :
Answer: D

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;
 } 

Options :
Answer: A

Viewing Page : 1 - 23
Practicing : 1 - 5 of 230 Questions

© Copyrights CertsIQ 2025. All Rights Reserved

We use cookies to ensure that we give you the best experience on our website (CertsIQ). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the CertsIQ.