Free C++ Institute CPA Exam Actual Questions

The questions for CPA were last updated On Nov 7, 2024

Question No. 1

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

#include

using namespace std;

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

{

int tab[5]={1,2,3};

for (int i=0; i<5; i++)

cout <

return 0;

}

Show Answer Hide Answer
Correct Answer: B

Question No. 2

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

#include

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;

}

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 First

{

public:

void Print(){ cout<<"from First";}

};

class Second

{

public:

void Print(){ cout<< "from Second";}

};

int main()

{

First FirstObject;

FirstObject.Print();

Second SecondObject;

SecondObject.Print();

}

Show Answer Hide Answer
Correct Answer: C

Question No. 4

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

#include

using namespace std;

int fun(int x) {

return x<<2;

}

int main(){

int i;

i = fun(1) / 2;

cout << i;

return 0;

}

Show Answer Hide Answer
Correct Answer: C

Question No. 5

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

#include

using namespace std;

int main()

{

int i=1;

for(;;)

{

cout<

if(i>5)

break;

}

return 0;

}

Show Answer Hide Answer
Correct Answer: C