×

Special Offer! Black Friday + Cyber Monday Sale! Extra 20% OFF - Ends In Coupon code: HELLO20OFF

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: 25 Nov, 2025
Question 1

Which code, inserted at line 8, generates the output "100"? #include using namespace std; int fun(int); int main() { int *x = new int; *x=10; //insert code here return 0; } int fun(int i) { return i*i; } 

Options :
Answer: A,B

Question 2

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 3

What happens when you attempt to compile and run the following code?

#include

using namespace std;

void print(char *c);

int main (int argc, const char * argv[])

{

print("Test");

return 0;

}

void print(char *c)

{

cout<

}

Options :
Answer: A

Question 4

What is the output of the program? #include using namespace std; #define SQR(x)(x*x) int main(int argc, char *argv[]) { int x, y=2; x = SQR(y); cout << x << ", " <

return 0;

}

Options :
Answer: B

Question 5

What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input? #include #include using namespace std; void f(); int main() { f(); return 0; } void f() { char c; c = cin.get(); cout << c; if(c != '\n') f(); }

Options :
Answer: A

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

© Copyrights FreeMockExams 2025. 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.