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: 21 Feb, 2026
Question 1

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:

Options :
Answer: A

Question 2

What happens when you attempt to compile and run the following code?
 #include <iostream>#include <map>
 #include <string>
 using namespace std;
 int main(){
 int second[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 10 };
 string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight"," ten"};
 map<int,string> m;
 for(int i=0; i<10; i++) {
 m.insert(pair<int,string>(second[i],first[i]));
 }
 if (m[11] == "eleven") {
 cout<<"eleven ";
 }
 for(map<int, string>::iterator i=m.begin();i!= m.end(); i++) {
 cout<<i?>second<<" ";
 }
 cout<<m.size();
 return 0;
 }

Options :
Answer: A

Question 3

What happens when you attempt to compile and run the following code?
 #include <iostream>#include <map>
 #include <string>
 using namespace std;
 int main(){
 int second[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 10 };
 string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight"," ten"};
 map<int,string> m;
 for(int i=0; i<10; i++) {
 m.insert(pair<int,string>(second[i],first[i]));
 }
 if (m[11] == "eleven") {
 cout<<"eleven ";
 }
 for(map<int, string>::iterator i=m.begin();i!= m.end(); i++) {
 cout<<i?>second<<" ";
 }
 cout<<m.size();
 return 0;
 }

Options :
Answer: A

Question 4

What happens when you attempt to compile and run the following code?
 #include <iostream>
 #include <algorithm>
 #include <vector>
 using namespace std;
 class A {
 int apublic:
 A(int a) : a(a) {}
 int getA() const { return a; } void setA(int a) { this?>a = a; }
 bool operator==(A & b) { return a == b.a; }
 };
 struct Compare{
 bool operator()(const A & a, const A & b) {return a.getA()==b.getA();};
 };
 int main () {
 int t[] = {1,2,3,4,5,1,2,3,4,5};
 vector<A> v (t,t+10);
 vector<A>::iterator it;
 A m1[] = {A(1), A(2), A(3)};
 it = search (v.begin(), v.end(), m1, m1+3, Compare());
 cout << "First found at position: " << it?v.begin() << endl;
 return 0;
 }
Program outputs:

Options :
Answer: B

Question 5

What happens when you attempt to compile and run the following code?
 #include <iostream>
 #include <set>
 #include <list>
 using namespace std;
 int main(){
 int t[] ={ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
 list<int>v(t, t+10);
 multiset<int> s1(v.begin(),v.end());
 if (s1.count(3) == 2) {
 s1.erase(3);
 }
 for(multiset<int>::iterator i=s1.begin();i!= s1.end(); i++) {
 cout<<*i<<" ";
 }
 return 0;
 } 

Options :
Answer: D

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

© Copyrights CertsIQ 2026. 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.