C++ Institute CPA Exam
C++ Certified Associate Programmer (Page 2 )

Updated On: 26-Jan-2026

What will the variable "age" be in class B?

class A {
int x;
protected:
int y;
public:
int age;
A () { age=5; };
};

class B : public A {
string name;
public:
B () { name="Bob"; };
void Print() {
cout << name << age;
}
};

  1. public
  2. private
  3. protected
  4. None of these

Answer(s): A



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

#include <iostream>

using namespace std;

int op(int x, int y);

int main()
{
int i=2, j=2, k;
float f=0.3;
k = op(i, j);
cout<< k << "," << op(1, f);
return 0;
}


int op(int x, int y)
{
return x+y;
}

  1. It prints: 4,1
  2. It prints: 4,0.7
  3. It prints: 4,0
  4. It prints: 0,4

Answer(s): A



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

#include <iostream>
using namespace std;

int main(){
int i = 1;
if (i++==1) {
cout << i;
} else {
cout << i-1;
}
return 0;
}

  1. It prints: 0
  2. It prints: 1
  3. It prints: -1
  4. It prints: 2

Answer(s): D



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;
}

  1. cout << myNamespace1::var << var;
  2. cout << var << var;
  3. cout << myNamespace1::var << myNamespace2::var;
  4. None of these

Answer(s): C



What will be the output of the program?

#include <iostream>

using namespace std;

int main()
{
const int y = 5;
const x = ?10;
cout<<x<<" "<<y;
return 0;
}

  1. ?10 5
  2. 5 ?10
  3. Compilation error
  4. None of these

Answer(s): C



Viewing page 2 of 45
Viewing questions 6 - 10 out of 220 questions



Post your Comments and Discuss C++ Institute CPA exam prep with other Community members:

Join the CPA Discussion