C++ Certified Professional Programmer

Here you have the best C++ Institute CPP practice exam questions

  • You have 228 total questions across 46 pages (5 per page)
  • These questions were last updated on February 19, 2026
  • This site is not affiliated with or endorsed by C++ Institute.
Question 1 of 228

What happens 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);
multiset<int> s1(v.begin(),v.end());
s1.insert(v.begin(),v.end());
pair<multiset<int>::iterator,multiset<int>::iterator> range; range = s1.equal_range(6); while (range.first != range.second) { cout<<*range.first<<" "; range.first++;
}
return 0;
}
Answer

Suggested Answer

The suggested answer is A.

Community Votes

No votes yet

Join the discussion to cast yours

Question 2 of 228

What happens when you attempt to compile and run the following code?
#include <vector>
#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<<" ";
}
};
struct Sequence {
int start;
Sequence(int start):start(start){}
int operator()() {
return start++ ; }};
int main() {
vector<int> v1(10);
generate(v1.rbegin(), v1.rend(), Sequence(1));
rotate(v1.begin(),v1.begin() + 1, v1.end() );
for_each(v1.begin(), v1.end(), Out<int>(cout) );cout<<endl; return 0;
}
Program outputs:
Answer

Suggested Answer

The suggested answer is C.

Community Votes

No votes yet

Join the discussion to cast yours

Question 3 of 228

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <fstream>
#include <string>
#include <list>
#include <algorithm>
#include <iomanip>
using namespace std;
class B { int val;
public:
B(int v=0):val(v){}
int getV() const {return val;}
operator int() const { return val; };};

template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) {out<<setw(3)<<hex<<val; } };

int main () {
int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
fstream f("test.out", ios::trunc|ios::out);
list<B> l(t, t+10);
for_each(l.begin(), l.end(), Out<B>(f));
f.close();
f.open("test.out");
for( ; f.good() ; ) {
B i;
f>>i;
cout<<i<<" ";
}
f.close();
return 0;
}
Answer

Suggested Answer

The suggested answer is D.

Community Votes

No votes yet

Join the discussion to cast yours

Question 4 of 228

What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: one two three<enter>?
#include <iostream>
#include <string>
using namespace std;

int main ()
{
string a;
cin>>a;
cout<<a<<endl;
return 0;
}
Program will output:
Answer

Suggested Answer

The suggested answer is A.

Community Votes

No votes yet

Join the discussion to cast yours

Question 5 of 228

What will happen 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, 3, 4, 1, 2, 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()));
}
pair<multimap<int, string>::iterator, multimap<int, string>::iterator> range; range = m.equal_range(2); for (multimap<int, string>::iterator i = range.first; i != range.second; i++) { cout << i?>first << " ";
}
return 0;
}

The output will be:
Answer

Suggested Answer

The suggested answer is A.

Community Votes

No votes yet

Join the discussion to cast yours

About the C++ Institute CPP Certification Exam

About the Exam

The C++ Institute CPP (C++ Certified Professional Programmer) validates your knowledge and skills. Passing demonstrates proficiency and can boost your career prospects in the field.

How to Prepare

Work through all 228 practice questions across 46 pages. Focus on understanding the reasoning behind each answer rather than memorizing responses to be ready for any variation on the real exam.

Why Practice Exams?

Practice exams help you familiarize yourself with the question format, manage your time, and reduce anxiety on the test day. Our CPP questions are regularly updated to reflect the latest exam objectives.