Skip to product information
1 of 1
Review of MS-721 pack
I’ve gotta say: this is the best investment I've made in my prep. I was able to study on my lunch breaks thanks to the PDF format and passed the MS-721 in just under two weeks of studying. The accuracy is just incredible.
Cillian Russell
99% pass rate. Pass or your money back. Fail the exam after using this pack and we refund you in full. How the guarantee works

C++ Institute CPP Exam Practice Questions

Every question comes with the correct answer and a clear explanation.

99% pass rate228 questions2 PDFs
Regular price $39.00 USD
Regular price Sale price $39.00 USD
Shipping calculated at checkout.

4.8 from 1,777 across all packs4.8 from 1,777 reviews across all packs

Delivered to your email within 24 hours.

  • Free updates for lifeEvery new version of this pack, emailed to you free.
  • Secure checkoutShop Pay, PayPal or card. Pay once, no subscription.
  • Questions-only copyA second PDF without the answers, for timed practice runs.
Review of MS-721 pack
I’ve gotta say: this is the best investment I've made in my prep. I was able to study on my lunch breaks thanks to the PDF format and passed the MS-721 in just under two weeks of studying. The accuracy is just incredible.
Cillian Russell
99% pass rate. Pass or your money back. Fail the exam after using this pack and we refund you in full. How the guarantee works
View full details
Try before you buy

Five of the 228 questions in this pack

Question 1

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

  1. A. program outputs: 6 6
  2. B. program outputs: 5 7
  3. C. program outputs: 5 5 6 6 7 7
  4. D. program outputs: 5 5 7 7
  5. E. program outputs: 1 1 6 6 5 5
Show answer and explanation

Correct answer: A. program outputs: 6 6

The multiset is filled with the ten values and then with the same ten again, so the value 6 is stored twice. equal_range(6) returns exactly those two elements, and the loop prints 6 twice.

Why the other options are wrong

  • B. equal_range(6) returns only elements equal to 6, never 5 or 7.
  • C. Neighbouring values are not included in the range, only the matching key.
  • D. The range holds only elements equal to 6, so 5 and 7 cannot appear.
  • E. Elements outside the equal range, such as 1 and 5, are not printed.
Question 2

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:

  1. A. 1 2 3 4 5 6 7 8 9 10
  2. B. 10 9 8 7 6 5 4 3 2 1
  3. C. 9 8 7 6 5 4 3 2 1 10
  4. D. 1 10 9 8 7 6 5 4 3 2
Show answer and explanation

Correct answer: C. 9 8 7 6 5 4 3 2 1 10

generate fills the vector through reverse iterators, so the values 1 to 10 go in from the back and the vector holds 10 9 8 ... 1. rotate then moves the first element to the end, giving 9 8 7 6 5 4 3 2 1 10.

Why the other options are wrong

  • A. That would need forward iterators and no rotation.
  • B. That is the state after generate and before the rotate call moves 10 to the end.
  • D. That would be a rotation to the right, but the code rotates left so that the second element becomes first.
Question 3

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

  1. A. file test.out will be opened writing
  2. B. file test.out will be truncated
  3. C. file test.out will be opened for reading
  4. D. compilation error
  5. E. program will display sequence 1 2 3 4 5 6 7 8 9 10
Show answer and explanation

Correct answer: D. compilation error

The line f>>i tries to extract into an object of class B, but B has no operator>> and its conversion to int cannot be used as a target for extraction. The code does not compile.

Why the other options are wrong

  • A. The program never gets as far as running, because it fails to compile.
  • B. The truncation would happen at run time, but the code does not compile.
  • C. Opening the file for reading would also be a run-time effect, which cannot happen without a successful compile.
  • E. The display depends on a program that cannot be built, so nothing is printed.
Question 4

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:

  1. A. one
  2. B. one two three
  3. C. runtime exception
  4. D. compilation error
  5. E. the result is unspecified
Show answer and explanation

Correct answer: A. one

The extraction operator reads one whitespace-delimited word into a string, so only "one" is stored and printed. The rest of the line stays in the input buffer.

Why the other options are wrong

  • B. Reading with >> stops at the first space, so the whole line is not stored.
  • C. Reading a string this way is valid and raises no exception.
  • D. The code is valid C++ and compiles.
  • E. The behavior of >> into a std::string is fully defined.
Question 5

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:

  1. A. 2 2
  2. B. 1 2
  3. C. 1 3
  4. D. 2
  5. E. 0 2
Show answer and explanation

Correct answer: A. 2 2

A multimap keeps duplicate keys, and the key 2 is inserted twice from the array. equal_range(2) covers both entries and the loop prints the key 2 twice.

Why the other options are wrong

  • B. Only entries with key 2 are in the range, so 1 is not printed.
  • C. The range holds keys equal to 2, so 1 and 3 do not appear.
  • D. Because a multimap allows duplicate keys, there are two entries and so two values are printed.
  • E. The key 0 is outside the range of key 2.

Download PDFGet the full pack, $39.00 USD

Try C++ Institute CPP free first

228 questions in the full pack
  • Free sample: 5 questions 5 real questions, every answer explained, in one PDF. Download PDF
  • Full pack, $39.00 USD paid once All 228 questions, every answer explained, plus a questions-only PDF. Updates for life.Get the full pack

CPP exam questions with answers: all 228 for the C++ Certified Professional Programmer exam.

This pack is the complete set, covering every part of the CPP-22-02 exam syllabus. Download the free sample to see the question style first.

  • 228 exam practice questions: mapped to the CPP-22-02 exam syllabus
  • Complete answers and explanations, including why every wrong option is wrong
  • Questions-only PDF: for timed practice
  • Email delivery: sent to your email within 24 hours
  • Free monthly updates for life

The CPP exam costs US$325. You pay for this PDF once, with a refund if you fail anyway.

CPP exam questions: the short answers

How many questions are on the CPP exam?
The exam has 40 questions, single-choice and multiple-choice. You have 65 minutes, plus about 10 minutes for the agreement and tutorial.

What score do I need to pass?
You need 70% of the available points. Each question is worth one point.

How much does the CPP exam cost?
The exam voucher is from US$325, or from US$375 with a retake included. The exam is delivered through Pearson VUE.

What makes this exam hard

The STL algorithms are the biggest part of the exam. Four of the nine syllabus blocks cover algorithms: non-modifying operations, modifying operations, sorting and binary search, and merge, heap, min and max. Expect output-prediction questions that ask what a short program prints, so you need to trace iterators and algorithm behavior by hand.

The remaining blocks cover sequence containers and container adapters, associative containers, STL functional objects and utilities, advanced I/O, and templates. Compile errors count as answers too, so check what the code actually allows before you work out the output.

Before you buy

Free questions

Real C++ Institute CPP questions are free on the site, each with the answer explained.

Free questions

What you get for $39.00 USD

  • All 228 questions, each with the correct answer and why the other options are wrong
  • 2 PDFs: the full pack, plus a questions-only copy for timed practice
  • Delivered to your email within 24 hours
  • Updated once a month, with free updates for life, emailed to the address you used at checkout
  • Paid once
What do I get?

Every pack comes as 2 PDFs: one with every answer explained, and a questions-only copy for timed practice. This pack is delivered to your email within 24 hours, and every pack includes free updates for life.

How often are the questions updated?

Question sets are updated once a month. The date of the latest update is shown on every exam page.

Will I receive updates after purchasing?

Yes. All PDF purchases include lifetime updates. Updated versions are emailed automatically to the email address used during checkout.

What if an answer looks wrong?

We correct mistakes as we find them, and the monthly update sends those fixes to you. No question bank this size is ever completely flawless, so if something still looks off to you, check it against the vendor's own documentation and send it to support@dailydebian.com. We reply to every message, and the fix ships in the next update, free, for life.

Are your materials enough to pass the exam?

Most candidates use them as their main practice source. If you study with them and still fail, we refund you in full.

What happens if I fail my exam?

You get your money back. Email support@dailydebian.com within 14 days of receiving your results, with your order number and a copy of your official score report showing the fail. Requests are reviewed within 5 to 7 business days and approved refunds go back to the original payment method. Full terms are in the refund policy.

Do you have discount codes?

Yes, when you buy more than one exam pack. For 2 packs, use code BUY2 for 15% off. For 3 or more packs, use code BUY3 for 20% off. Enter the code in the discount box at checkout.

What payment methods do you accept?

Visa, Mastercard, American Express, UnionPay, Apple Pay, Google Pay, Shop Pay and PayPal. All prices are shown in your local currency at checkout.

Do you offer shipping?

No. All products are digital downloads. There is no physical shipping.

I did not receive my order after payment.

Contact support@dailydebian.com with your order number and payment confirmation details.