Free CPA-21-02 Mock Exam – Practice Online Confidently

Increase your chances of passing the C++ Institute CPA-21-02 exam questions on your first try. Practice with our free online CPA-21-02 exam mock test designed to help you prepare effectively and confidently.

Exam Code: CPA-21-02
Exam Questions: 257
CPA C++ Certified Associate Programmer
Updated: 18 Feb, 2026
Question 1

What happens if characters 'w', 'o', 'r', 'l' and 'd' are entered as input? #include #include using namespace std; int main() { string s1 = "Hello"; string s2; getline( cin, s2 ); cout << s1 + s2; return( 0 ); } 

Options :
Answer: A

Question 2

What is the output of the program given below? #include using namespace std; int main (int argc, const char * argv[]) { enum state { ok, error, warning}; enum state s1, s2, s3, s4;  s1 = ok; s2 = warning; s3 = error; s4 = ok; cout << s1<< s2<< s3<< s4; return 0; }

Options :
Answer: C

Question 3

What happens when you attempt to compile and run the following code? #include using namespace std; int main() { int i, j; for(i = 0; i < 2; i++) { for(j = i; j < i + 1; j++) if(j == i) continue; else break; } cout << j; return 0; }

Options :
Answer: C

Question 4

What is the output of the program given below? #include using namespace std; int main (int argc, const char * argv[]) { enum state { ok, error, warning}; enum state s1, s2, s3, s4;  s1 = ok; s2 = warning; s3 = error; s4 = ok; cout << s1<< s2<< s3<< s4; return 0; }

Options :
Answer: C

Question 5

What will be the output of the program? #include using namespace std; int fun(int); int main() { cout << fun(5); return 0; } int fun(int i) { return i*i; }

Options :
Answer: A

Viewing Page : 1 - 26
Practicing : 1 - 5 of 257 Questions

© Copyrights FreeMockExams 2026. All Rights Reserved

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