Confidently Practice Online with Free CPP-22-02 Exam Cram

Practice your CPP - C++ Certified Professional Programmer certification test with free CPP-22-02 exam cram and take control of your certification preparation. At FreeExamCram, you can practice online for free using real CPP-22-02 exam dumps, verified questions, and expert-designed free online practice tests. Moreover our C++ Institute CPP-22-02 exam cram backed by our confidence-boosting refund guarantee.

Exam Code: CPP-22-02
Exam Questions: 230
CPP - C++ Certified Professional Programmer
Updated: 16 Apr, 2026
Viewing Page : 1 - 23
Practicing : 1 - 5 of 230 Questions
Question 1

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;
 }
 struct sequence {
 int val,inc;
 sequence(int s, int i):val(s),inc(i){}
 int operator()(){
 int r = val; val += inc;
 return r;
 }
 };
 int main() {
 vector<int> v1(10);fill(v1.begin(), v1.end(), sequence(1,1));
 for_each(v1.begin(), v1.end(), myfunction);
 return 0;
 }
Program outputs:

Options :
Answer: D

Question 2

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

Options :
Answer: A

Question 3

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

Question 4

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 5

What happens when you attempt to compile and run the following code?
 #include <deque>
 #include <iostream>#include <algorithm>
 #include <functional>
 using namespace std;
 class B { int val;
 public:
 B(int v):val(v){}
 int getV() const {return val;} bool operator > (const B & v) const { return val>v.val;} };
 ostream & operator <<(ostream & out, const B & 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<<" "; } };
 int main() {
 int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20};
 deque<B> d1(t, t+10);
 sort(d1.begin(), d1.end(), greater<B>());
 pair<deque<B> ::iterator, deque<B>::iterator > result = equal_range(d1.begin(), d1.end(),
B(20), greater<B>());
 for_each(result.first, result.second, Out<B>(cout));cout<<endl;
 return 0;
 }
Program outputs:

Options :
Answer: B

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

© Copyrights FreeExamCram 2026. All Rights Reserved

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