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

Updated On: 26-Jan-2026

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

#include <iostream>

using namespace std;

int op(int x, int y);
float op(int x, float y);


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

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


float op(int x, float y)
{
return x?y;
}

  1. It prints: 3,1
  2. It prints: 3,?0.3
  3. It prints: 3,0
  4. It prints: 0,0

Answer(s): B



Which code, inserted at line 10, generates the output "2?1"?

#include <iostream>
#include <string>
using namespace std;
class A {
protected:
int y;
public:
int z;
};
//insert code here
public:
void set() {
y = 2;
z = 3;
}
void Print() { cout << y << z; }
};


int main () {
B b;
b.set();
b.z = ?1;
b.Print();
return 0;
}

  1. class B : private A {
  2. class B : public A {
  3. class B : protected A {
  4. class B {

Answer(s): B



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

#include <iostream>

using namespace std;

class First
{
public:
void Print(){ cout<<"from First";}
};
class Second:public First
{
public:
void Print(){ cout<< "from Second";}
};
void fun(First *obj);
int main()
{
First FirstObject;
fun(&FirstObject);
Second SecondObject;
fun(&SecondObject);
}
void fun(First *obj)
{
obj?>Print();
}

  1. It prints: from First
  2. It prints: from Firstfrom First
  3. It prints: from Firstfrom Second
  4. It prints: from Secondfrom Second

Answer(s): B



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

#include <iostream>

using namespace std;

int f(int a, int b);

int main()
{
float b;
b = f(20,10);
cout << b;
return 0;
}

int f(int a, int b)
{
return a/b;
}

  1. It prints: 2
  2. It prints: 5
  3. It prints: 10
  4. It prints: 0

Answer(s): A



If there is one, point out an error in the program

#include <iostream>

using namespace std;

int main()
{
int i=1;
for(;;)
{
cout<<i++;
if(i>5)
break;
}
return 0;
}

  1. Error in “if” statement
  2. Error in “for” loop
  3. No error
  4. Error in break statement

Answer(s): C



Viewing page 4 of 45
Viewing questions 16 - 20 out of 220 questions



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

Join the CPA Discussion