Weekend Special 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: save70

C++ Institute CPA Actual Questions

Page: 5 / 8
Total 220 questions

C++ Certified Associate Programmer Questions and Answers

Question 17

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

#include

using namespace std;

int main(){

int i = 1;

if (--i==1) {

cout << i;

} else {

cout << i-1;

}

return 0;

}

Options:

A.

It prints: 0

B.

It prints: 1

C.

It prints: -1

D.

It prints: 2

Question 18

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 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();

}

Options:

A.

It prints: from First

B.

It prints: from Firstfrom First

C.

It prints: from Firstfrom Second

D.

It prints: from Secondfrom Second

Question 19

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

#include

using namespace std;

int mul (int a, int b=2)

{

int r;

r=a*b;

return (r);

}

int main ()

{

cout << mul(1) << mul(2,4);

return 0;

}

Options:

A.

It prints: 2

B.

It prints: 28

C.

It prints: 8

D.

It prints: 6

Question 20

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

#include

#include

using namespace std;

int f(int i);

int main()

{

int i=0;

i++;

for (i=0; i<=2; i++)

{

cout<<f(i);

}

return 0;

}

int f(int a)

{

return a+a;

}

Options:

A.

It prints: 202020

B.

It prints: 012

C.

It prints: 024

D.

It prints: 0

Page: 5 / 8
Total 220 questions