All Practice Exams

100+ Free C++ CPA Practice Questions

Pass your C++ Institute Certified Associate Programmer exam on the first try — instant access, no signup required.

✓ No registration✓ No credit card✓ No hidden fees✓ Start practicing immediately
Not published Pass Rate
100+ Questions
100% Free
1 / 100
Question 1
Score: 0/0

Which header must be included to use std::cout for console output in standard C++?

A
B
C
D
to track
2026 Statistics

Key Facts: C++ CPA Exam

40

Exam Questions

C++ Institute CPA-21-02 syllabus

65 min

Exam Duration

C++ Institute CPA-21-02 syllabus

70%

Passing Score

C++ Institute CPA-21-02 syllabus

$325

Exam Fee (USD)

C++ Institute pricing

Pearson VUE

Test Provider

C++ Institute / OnVUE

Lifetime

Validity

C++ Institute certification policy

C++ Institute CPA (CPA-21-02) is a 40-item, 65-minute proctored exam delivered by Pearson VUE/OnVUE, with a 70% passing score and a starting fee of USD 325 (USD 375 with one retake). Topics: types and operators (24.5%), control and exceptions (18%), functions and preprocessor (17.5%), pointers (11%), and classes and namespaces (29%). The certification is issued for life with no recertification required.

Sample C++ CPA Practice Questions

Try these sample questions to test your C++ CPA exam readiness. Each question includes a detailed explanation. Start the interactive quiz above for the full 100+ question experience with AI tutoring.

1Which header must be included to use std::cout for console output in standard C++?
A.<iostream>
B.<stdio.h>
C.<cstdlib>
D.<string>
Explanation: std::cout, std::cin, std::cerr, and std::clog are declared in <iostream>. <stdio.h> is the C header for printf/scanf, <cstdlib> exposes general utilities like std::exit, and <string> declares std::string but not the streams.
2What does the following snippet print? #include <iostream> int main() { int x = 5; int y = 2; std::cout << x / y << " " << x % y; return 0; }
A.2 1
B.2.5 1
C.2 0.5
D.3 1
Explanation: Both operands are int, so / performs integer division: 5 / 2 truncates toward zero to 2. The remainder operator % gives 5 % 2 = 1. The output is therefore '2 1' separated by a single space.
3Which statement about C++ identifiers is TRUE?
A.Identifiers can contain letters, digits, and underscores, but the first character cannot be a digit.
B.Identifiers may begin with a digit if they contain at least one letter.
C.Identifiers can contain spaces if surrounded by underscores.
D.Identifiers are limited to a maximum length of eight characters.
Explanation: A valid C++ identifier is a sequence of letters, digits, and underscores that starts with a letter or an underscore — never a digit. There is no portable maximum length, identifiers cannot contain whitespace, and reserved words cannot be used as identifiers.
4What does the following code print? #include <iostream> int main() { int a = 10; int b = 3; std::cout << a + b * 2; return 0; }
A.16
B.26
C.13
D.20
Explanation: Multiplication has higher precedence than addition, so b * 2 evaluates first to 6, then a + 6 yields 16. Without parentheses, C++ never overrides standard arithmetic precedence.
5Which of the following is the correct way to declare a constant integer in C++?
A.const int MAX = 100;
B.constant int MAX = 100;
C.int const MAX == 100;
D.#const int MAX 100
Explanation: The const qualifier is placed before (or after) the type to declare a read-only variable: const int MAX = 100;. C++ has no 'constant' keyword, == is comparison not assignment, and #const is not a valid preprocessor directive.
6What is the output of the following code? #include <iostream> int main() { int i = 5; std::cout << i++ << " " << ++i; return 0; }
A.Undefined behavior — order of evaluation of subexpressions in a single statement was unspecified before C++17
B.5 6
C.5 7
D.6 7
Explanation: Pre-C++17, modifying the same scalar variable more than once between sequence points without an intervening sequencing produced undefined behavior, which is exactly what i++ and ++i on the same i in a single output statement do. C++17 sequenced << operands left-to-right, but the multiple unsequenced modifications of i in this single full-expression are still problematic on the CPA-21-02 exam, which treats this as undefined behavior.
7Which of these is NOT a fundamental built-in type in C++?
A.string
B.char
C.double
D.bool
Explanation: string is not a built-in fundamental type — std::string is a class template instantiation declared in <string>. char, double, and bool are fundamental types defined by the language itself.
8What does this snippet print? #include <iostream> int main() { bool b = 5; std::cout << b << " " << !b; return 0; }
A.1 0
B.5 0
C.true false
D.0 1
Explanation: Any non-zero integer assigned to bool becomes true (stored as 1). Default stream output for bool prints integers, so true is shown as 1. !b negates true to false, which prints as 0. The result is '1 0'.
9Which statement about a C++ literal like 3.14 is TRUE?
A.It has type double by default.
B.It has type float by default.
C.It has type long double by default.
D.Its type depends on the surrounding variable.
Explanation: An unsuffixed floating-point literal in C++ has type double. To get float you must add the suffix f or F (3.14f), and L produces long double (3.14L). The literal type is fixed by the literal itself, not by context.
10What does this code print? #include <iostream> int main() { int a = 7; int b = 4; std::cout << (a > b ? a : b); return 0; }
A.7
B.4
C.1
D.0
Explanation: The conditional (ternary) operator evaluates a > b. Since 7 > 4 is true, the expression yields a, which is 7. The pattern (cond ? x : y) returns x when cond is true, y otherwise.

About the C++ CPA Exam

The C++ Institute CPA (CPA-21-02) credential validates the candidate's ability to write, debug, and run programs in C++ at the associate level. The exam covers C++ types and operators, control flow and exceptions, functions and the preprocessor, pointers and dynamic memory, plus introductory OOP with classes, inheritance, polymorphism, virtual functions, and namespaces.

Questions

40 scored questions

Time Limit

65 minutes

Passing Score

70%

Exam Fee

$325 USD (C++ Institute)

C++ CPA Exam Content Outline

29%

Classes and Namespaces

OOP fundamentals: class design, access specifiers, constructors and destructors, inheritance, polymorphism with virtual functions, casting, and namespace usage.

24.5%

Types and Operators

Built-in types, literals, std::string operations, arrays and std::vector basics, type casting, declaration modifiers, and the full set of C++ operators.

18%

Control Flow and Exceptions

if/else, switch, while, do-while, and for loops, break and continue, plus exception handling with try, catch, throw, and standard exception hierarchies.

17.5%

Functions and Preprocessor Directives

Function definitions, parameter passing by value and reference, default arguments, overloading, recursion, inline functions, and #include / #define / conditional compilation.

11%

Pointers and Dynamic Memory

Pointer declaration and dereferencing, pointer arithmetic, the relationship between arrays and pointers, and dynamic memory management with new and delete.

How to Pass the C++ CPA Exam

What You Need to Know

  • Passing score: 70%
  • Exam length: 40 questions
  • Time limit: 65 minutes
  • Exam fee: $325 USD

Keys to Passing

  • Complete 500+ practice questions
  • Score 80%+ consistently before scheduling
  • Focus on highest-weighted sections
  • Use our AI tutor for tough concepts

C++ CPA Study Tips from Top Performers

1Compile and run every code snippet you study — CPA-21-02 is heavy on 'what does this print' and 'which line fails to compile' questions, so reasoning on paper is not enough.
2Master the difference between pass-by-value, pass-by-reference, and pass-by-pointer in functions, and know which one is required to mutate the caller's variable.
3Memorize the order constructors and destructors run for inheritance: base constructors run first, derived destructors run first.
4Practice virtual function dispatch: when a base class pointer or reference holds a derived object, only methods marked virtual call the derived version.
5Drill operator precedence and associativity, especially the unary operators ++, --, *, &, and how postfix differs from prefix.
6Know the array-to-pointer decay rule and why sizeof(array) inside a function returns the pointer size, not the array size.
7Learn the full int/short/long/char promotion rules used by arithmetic operators — these drive a surprising number of output questions.
8Build a small inheritance hierarchy in a Personal C/C++ Education Platform sandbox and exercise public, protected, and private inheritance to feel the access differences.

Frequently Asked Questions

What is on the C++ Institute CPA exam?

CPA-21-02 tests C++ fundamentals at the associate level: types and operators (24.5%), control flow and exceptions (18%), functions and preprocessor directives (17.5%), pointers and dynamic memory (11%), and classes and namespaces (29%) including inheritance, polymorphism, virtual functions, and casting. It does not go deep into templates, the STL beyond std::string and std::vector basics, or advanced exception design — those belong to the CPP follow-on exam.

How long is the CPA exam and how many questions does it have?

The C++ Institute CPA-21-02 exam consists of 40 single-select and multiple-select questions delivered in 65 minutes, plus about 10 additional minutes for the non-disclosure agreement and tutorial. Each question carries a weight that depends on its complexity, and your final score is normalized to a percentage out of 200 total points.

What is the passing score for C++ CPA?

You must score 70% or higher on the CPA-21-02 exam to pass. Because items are weighted, the 70% threshold is calculated against the total points earned across all 40 questions, not a simple count of correct answers.

How much does the C++ Institute CPA exam cost?

The CPA-21-02 exam starts at USD 325 for a single attempt or USD 375 for the exam plus one retake voucher. Candidates who complete the official CPA self-study course on the C/C++ Education Platform can earn a 50% discount voucher, which also includes one free retake.

Where do I take the CPA exam?

You schedule and take the C++ Institute CPA exam through Pearson VUE, either at a Pearson VUE test center or through OnVUE online proctoring. You set up a Pearson VUE account at pearsonvue.com/cpp, choose CPA-21-02, and pick your delivery method and time slot.

Does the CPA certification expire?

No. C++ Institute certificates, including CPA, are issued for life with no recertification or renewal fees. Once you pass CPA-21-02 your credential remains valid permanently, although the institute reserves the right to update policies in the future.