Online Access Free CPA Exam Questions

Exam Code:CPA
Exam Name:C++ Certified Associate Programmer
Certification Provider:C++ Institute
Free Question Number:220
Posted:Nov 26, 2026
Rating
100%

Question 1

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

Question 2

What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
#define DEF_A 0
int main(int argc, char *argv[]) {
cout << DEF_A;
return 0;
}

Question 3

Which code, inserted at line 12, generates the output "5b"?
#include <iostream> using namespace std; namespace myNamespace1 { int var = 5; } namespace myNamespace2 { char var = 'b'; } int main () { //insert code here return 0; }

Question 4

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

Question 5

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
public:
A() { cout << "A no parameters";}
A(string s) { cout << "A string parameter";}
A(A &a) { cout << "A object A parameter";}
};
class B : public A {
public:
B() { cout << "B no parameters";}
B(string s) { cout << "B string parameter";}
};
int main () {
A a2("Test");
B b1("Alan");
B b2(b1);
return 0;
}

Add Comments

Your email address will not be published. Required fields are marked *

insert code
Type the characters from the picture.