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

Pass Using CPA Exam Dumps

Page: 2 / 8
Total 220 questions

C++ Certified Associate Programmer Questions and Answers

Question 5

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

#include

using namespace std;

int main()

{

int x=20;

int *ptr;

ptr = &x;

cout<<*ptr;

return 0;

}

Options:

A.

It prints: 20

B.

It prints: 0

C.

It prints address of ptr

D.

It prints: 2

Question 6

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

#include

#include

using namespace std;

class B;

class A {

int age;

public:

A () { age=5; };

friend class B;

};

class B {

string name;

public:

B () { name="Bob"; };

void Print(A ob) {

cout << name << ob.age;

}

};

int main () {

A a;

B b;

b.Print(a);

return 0;

}

Options:

A.

It prints: Bob5

B.

It prints: Bob

C.

It prints: 5

D.

None of these

Question 7

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

#include

#include

using namespace std;

inline float sum(float a,float b)

{

return a+b;

}

int main()

{

float a,b;

a = 1.5; b = 3.4;

cout<<sum(a,b);

return 0;

}

Options:

A.

It prints: 0

B.

It prints: 4.9

C.

It prints: 5

D.

It prints: 4

Question 8

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

#include

#include

using namespace std;

class A {

public:

int x;

A() { x=0;}

A(int x) { this?>x=x;}

};

class B : private A {

public:

using A::x;

B() { x=1;}

B(int x) {this?>x = x;}

};

int main () {

B c1;

B c2(?5);

cout << c1.x;

cout << c2.x;

return 0;

}

Options:

A.

It prints: 5

B.

It prints: 1?5

C.

It prints: 05

D.

It prints: 0

Page: 2 / 8
Total 220 questions