Summer Certification Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code = getmirror

Pass the C++ Institute C++ Certified Professional Programmer CPA-21-02 Questions and answers with ExamsMirror

Practice at least 50% of the questions to maximize your chances of passing.
Exam CPA-21-02 Premium Access

View all detail and faqs for the CPA-21-02 exam


788 Students Passed

91% Average Score

96% Same Questions
Viewing page 6 out of 8 pages
Viewing questions 51-60 out of questions
Questions # 51:

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<

return 0;

}

Options:

A.

It prints: 0

B.

It prints: 4.9

C.

It prints: 5

D.

It prints: 4

Questions # 52:

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

#include

using namespace std;

int main()

{

float x=3.5,y=1.6;

int i,j=2;

i = x + j + y;

cout << i;

return 0;

}

Options:

A.

It prints: 7

B.

It prints: 6

C.

It prints: 7,1

D.

Compilation error

Questions # 53:

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

#include

using namespace std;

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

{

int x,y;

union t

{

char tab[2];

int i;

};

union t u;

u.tab[0] = 1;

u.tab[1] = 2;

u.i = 0;

x = u.tab[0];

y = u.tab[1];

cout << x << "," << y << "," << u.i;

return 0;

}

Options:

A.

compilation fails

B.

It prints: 0,0,0

C.

It prints: 1,2,0

D.

None of these

Questions # 54:

How could you pass arguments to functions?

Options:

A.

by value

B.

by reference

C.

by pointer

D.

by void

Questions # 55:

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

#include

using namespace std;

class A {

public :

void print() {

cout << "A ";

}

};

class B {

public :

void print() {

cout << "B ";

}

};

int main() {

B sc[2];

A *bc = (A*)sc;

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

(bc++)->print();

return 0;

}

Options:

A.

It prints: A A

B.

It prints: B B

C.

It prints: A B

D.

It prints: B A

Questions # 56:

What is the output of the program?

#include

#include

using namespace std;

struct Person {

int age;

};

class First

{

Person *person;

public:

First() {person = new Person;

person?>age = 20;

}

void Print(){

cout << person?>age;

}

};

int main()

{

First t[2];

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

t[i].Print();

}

Options:

A.

It prints: 10

B.

It prints: 2020

C.

It prints: 22

D.

It prints: 00

Questions # 57:

Which code, inserted at line 10, generates the output "Hello World"?

#include

#include

using namespace std;

string fun(string, string);

int main()

{

string s="Hello";

string *ps;

ps = &s;

//insert code here

return 0;

}

string fun(string s1, string s2)

{

return s1+s2;

}

Options:

A.

cout << fun(" World");

B.

cout << fun(*ps);

C.

cout << fun("Hello");

D.

cout << fun("Hello", " World");

Questions # 58:

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

#include

using namespace std;

void set(struct person*);

struct person

{

int age;

};

int main()

{

struct person e = {18};

set(&e);

cout<< e.age;

return 0;

}

void set(struct person *p)

{

p?>age = p?>age + 1;

}

Options:

A.

It prints: 18

B.

It prints: 19

C.

It prints: 20

D.

It prints: 0

Questions # 59:

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

#include

using namespace std;

int s(int n);

int main()

{

int a;

a = 3;

cout << s(a);

return 0;

}

int s(int n)

{

if(n == 0) return 1;

return s(n?1)*n;

}

Options:

A.

It prints: 4

B.

It prints: 6

C.

It prints: 3

D.

It prints: 0

Questions # 60:

What will be the output of the program?

#include

using namespace std;

int fun(int);

int main()

{

cout << fun(5);

return 0;

}

int fun(int i)

{

return i*i;

}

Options:

A.

25

B.

5

C.

0

D.

1

Viewing page 6 out of 8 pages
Viewing questions 51-60 out of questions
TOP CODES

TOP CODES

Top selling exam codes in the certification world, popular, in demand and updated to help you pass on the first try.