Free C++ Institute CPA Exam Actual Questions

The questions for CPA were last updated On Jan 11, 2025

Question No. 1

What is the output of the program given below?

#include

using namespace std;

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

{

float f=?10.501;

cout<<(int)f;

}

Show Answer Hide Answer
Correct Answer: C

Question No. 2

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

#include

#include

using namespace std;

int mult(int f, int s, int t);

int main()

{

cout << mult(1,2,3);

return 0;

}

int mult(int f, int s, int t)

{

int mult_res;

mult_res = f*s*t;

return mult_res;

}

Show Answer Hide Answer
Correct Answer: B

Question No. 3

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

#include

using namespace std;

class complex{

double re;

double im;

public:

complex() : re(0),im(0) {}

complex(double x) { re=x,im=x;};

complex(double x,double y) { re=x,im=y;}

void print() { cout << re << " " << im;}

};

int main(){

complex c1;

double i=2;

c1 = i;

c1.print();

return 0;

}

Show Answer Hide Answer
Correct Answer: D

Question No. 4

What is the output of the program?

#include

using namespace std;

class BaseC

{

int i;

public:

BaseC() { i=?1;}

BaseC(int i) { i=i; }

void seti(int a) { i = a; };

void Print() { cout << i; }

};

int main()

{

BaseC *o = new BaseC();

o?>seti(10);

o?>Print();

}

Show Answer Hide Answer
Correct Answer: A

Question No. 5

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

#include

using namespace std;

int compare(int, int);

int main()

{

int x = compare(10, 20);

cout << x;

return 0;

}

int compare(int i, int j)

{

return i

}

Show Answer Hide Answer
Correct Answer: C