C++ Institute CPA Exam Questions
C++ Certified Associate Programmer (Page 3 )

Updated On: 21-Feb-2026

What will be the output of the program?

#include <iostream>

using namespace std;

int fun(int);

int main()
{
cout << fun(5);
return 0;
}


int fun(int i)
{
return i*i;
}

  1. 25
  2. 5
  3. 0
  4. 1

Answer(s): A



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

#include <iostream>

using namespace std;

#define FUN(arg) if(arg) cout<<"Test";

int main()
{
int i=1;
FUN(i<3);
return 0;
}

  1. It prints: 0
  2. It prints: T
  3. It prints: T0
  4. It prints: Test

Answer(s): D



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

class A {
int x;
protected:
int y;
public:
int age;
};


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

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

Answer(s): B



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

#include <iostream>

using namespace std;

int main()
{
float x=3.5,y=1.6;
int i,j=2;
i = x + j + y;
cout << i;
return 0;
}

  1. It prints: 7
  2. It prints: 6
  3. It prints: 7,1
  4. Compilation error

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): B






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

Join the CPA Discussion