C++Institute C++ Certified Associate Programmer

C++Institute CPA Exam Dumps

C++ Certified Associate Programmer

Exam code
CPA
Questions
220
Updated
25 Nov 2026
  • Instant access from My Account after payment
  • 90 days of free updates
  • Money-back guarantee – see conditions
  • Help by live chat or email
Choose a format
Try free sample questions

Prices in USD. Downloads appear in My Account once your order is complete.

  • Instant access from My Account after payment
  • 90 days of free updates
  • Money-back guarantee – see conditions
  • Help by live chat or email
Free demo

CPA sample questions

Check the style and quality of the material before you buy.

Question 1

What happens when you attempt to compile and run the following code?#include <iostream> using namespace std; int main() { int i=5; switch(i) { case 1: cout<<"Hello"; break; case 2: cout<<"world"; break; case 3: break; default: cout<<"End"; }  return 0; }

  • A. It prints: Hello 
  • B. It prints: world 
  • C. It prints: End 
  • D. It prints: Helloworld 

Answer: C

Question 2

What happens when you attempt to compile and run the following code?#include <iostream> using namespace std; int fun(int x) { return 2*x; } int main(){ int i; i = fun(1) || fun(2); cout << i; return 0; }

  • A. It prints: 0 
  • B. It prints: 1 
  • C. It prints: -1 
  • D. Compilation error 

Answer: B

Question 3

What happens when you attempt to compile and run the following code?#include <iostream> #include <string> using namespace std; int main() { string s1[]= {"H" , "t" }; string s; for (int i=0; i<2; i++) { s = s1[i]; s.insert(1,"o"); cout << s; } return( 0 ); }

  • A. It prints: Hoto 
  • B. It prints: Ho 
  • C. It prints: to 
  • D. It prints: Ht 

Answer: A

Question 4

What is the output of the program?#include <iostream> #include <string>  using namespace std; class First { string name; public: First() { name = "Alan"; } void setName(string n) {this?>name = n;} void setName() {this?>name = "John";} void Print(){ cout << name; } }; int main() { First ob1,*ob2; ob2 = new First(); First *t; t = &ob1; t?>setName(); t?>Print(); t = ob2; t?>setName("Steve"); ob2?>Print(); }

  • A. It prints: JohnSteve 
  • B. It prints: AlanAlan 
  • C. It prints: AlanSteve 
  • D. It prints: Johnlan

Answer: A

Question 5

What happens when you attempt to compile and run the following code?#include <iostream> #include <string> using namespace std; class A { protected: int y; public: int x, z; A() : x(1), y(2), z(0) {} A(int a, int b) : x(a), y(b) { z = x * y;} void Print() { cout << z; } }; class B : public A { public: int y; B() : A() {} B(int a, int b) : A(a,b) {} void Print() { cout << z; } }; int main () { A b(2,5); b.Print(); return 0; }

  • A. It prints: 10 
  • B. It prints: 2 
  • C. It prints: 5 
  • D. It prints: 1 

Answer: A

Question 6

What happens when you attempt to compile and run the following code?#include <iostream> #include <string> using namespace std; class SampleClass { string *s; public: SampleClass() { s = new string("Text");} SampleClass(string s) { this?>s = new string(s);} ~SampleClass() { delete s;} void Print(){ cout<<*s;} }; int main() { SampleClass *obj; obj = new SampleClass("Test"); obj?>Print(); }

  • A. It prints: Text 
  • B. It prints: Test 
  • C. It prints: TextTest 
  • D. Garbage value. 

Answer: B

Question 7

What happens when you attempt to compile and run the following code?#include <iostream> using namespace std; int main (int argc, const char * argv[]) { int tab[5]={1,2,3}; for (int i=0; i<5; i++) cout <<tab[i]; return 0; }

  • A. compilation fails 
  • B. It prints: 12300 
  • C. It prints: 12345 
  • D. It prints: 00000 

Answer: B

Question 8

What happens when you attempt to compile and run the following code?#include <iostream> using namespace std; class First { public: void Print(){ cout<<"from First";} }; class Second:public First { public: void Print(){ cout<< "from Second";} };void fun(First *obj); int main() { First FirstObject; fun(&FirstObject); Second SecondObject; fun(&SecondObject); } void fun(First *obj) { obj?>Print(); }

  • A. It prints: from First 
  • B. It prints: from Firstfrom First 
  • C. It prints: from Firstfrom Second 
  • D. It prints: from Secondfrom Second 

Answer: B

Question 9

What will be the output of the program?#include <iostream> #include <string> using namespace std;  int fun(int); int main() { float k=3; k = fun(k); cout<<k; return 0; } int fun(int i) { i++; return i; }

  • A. 3 
  • B. 5 
  • C. 4 
  • D. 5 

Answer: C

Question 10

Which code, inserted at line 19, generates the output "23"?#include <iostream> #include <string> using namespace std; class A { int x; protected: int y; public: int z; A() { x=1; y=2; z=3; } }; class B : public A { string z; public: int y; void set() { y = 4; z = "John"; } void Print() { //insert code here } }; int main () { B b; b.set(); b.Print(); return 0; }

  • A. cout << y << z
  • B. cout << y << A::z; 
  • C. cout << A::y << A::z; 
  • D. cout << B::y << B::z; 

Answer: C

Why Dumpsforsure is the best choice for C++Institute CPA exam preparation

Secure your position in a competitive IT industry

The C++Institute CPA certification is a strong way to demonstrate your understanding and ability. Our CPA questions & answers help you prepare for it, so you can secure your current position and move your career forward.

Reviewed by IT professionals

We keep our CPA exam dumps up to date, with explanations. The questions and answers on Dumpsforsure are reviewed by people with professional experience of C++Institute technologies.

One place to prepare

Dumpsforsure brings together the material you need for the C++Institute CPA exam. Explanations are added to the questions to help you understand the logic behind them and prepare for other C++Institute exams.

Updated CPA questions & answers

We update the exam files regularly to add new questions. The date of the latest update is shown at the top of this page.

Free CPA demo before you buy

You can view sample CPA questions on this page before buying, to see the format and pattern of the material.

90 days of free updates

You are eligible for 90 days of free updates after buying the CPA exam. If the file is updated in that time, you can download the latest version from your account.

Ready to prepare?

C++Institute CPA · 220 questions

Choose a format