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

Viewing page 4 out of 8 pages
Viewing questions 31-40 out of questions
Questions # 31:

Which of the following is a user defined data type?

1:

struct person

{

char name[20];

int age;

};

2:

int l=2;

3:

enum color {red,blue, green};

D.

char c;

Options:

A.

1


B.

2


C.

3


D.

4


Expert Solution
Questions # 32:

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

#include

using namespace std;

int main()

{

long int x,y=10;

double d;

d = 3.99;

x=(int) d;

cout << x <<", ";

d=float (y);

cout << d;

return 0;

}

Options:

A.

It prints: 3, 10


B.

It prints: 3.99, 10


C.

It prints: 4, 10.0


D.

It prints: 4, 10


Expert Solution
Questions # 33:

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

#include

using namespace std;

int fun(int x) {

return 2*x;

}

int main(){

int i;

i = fun(1) || fun(2);

cout << i;

return 0;

}

Options:

A.

It prints: 0


B.

It prints: 1


C.

It prints: -1


D.

Compilation error


Expert Solution
Questions # 34:

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

Question # 34

Options:

A.

It prints: MaxNiels


B.

It prints: RobertMax


C.

It prints: RobertNiels


D.

It causes a compilation error


Expert Solution
Questions # 35:

Which of the following expressions decrement variable i by 2? (Choose two.)

Options:

A.

i &= 0x03;


B.

i –= 2;


C.

––i; i––;


D.

––i––;


Expert Solution
Questions # 36:

What is the output of the program?

#include

#include

using namespace std;

struct t

{

int tab[2];

};

class First

{

struct t u;

public:

First() {

u.tab[0] = 1;

u.tab[1] = 0;

}

void Print(){

cout << u.tab[0] << " " << u.tab[1];

}

};

int main()

{

First t;

t.Print();

}

Options:

A.

It prints: 2 2


B.

It prints: 1 1


C.

It prints: 1 0


D.

It prints: 0 0


Expert Solution
Questions # 37:

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

}

Options:

A.

It prints: 10


B.

It prints: ?1


C.

It prints: 0


D.

Compilation error


Expert Solution
Questions # 38:

Which code, inserted at line 8, generates the output "100"?

#include

using namespace std;

int fun(int);

int main()

{

int *x = new int;

*x=10;

//insert code here

return 0;

}

int fun(int i)

{

return i*i;

}

Options:

A.

cout << fun(*x) ;


B.

cout << fun(10);


C.

cout << fun(5) ;


D.

cout << fun(y) ;


Expert Solution
Questions # 39:

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

Question # 39

Options:

A.

It prints: 4


B.

It prints: 1


C.

It causes a compilation error


D.

lit prints: 0


Expert Solution
Questions # 40:

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

#include

using namespace std;

int main()

{

int i=2;

switch(i)

{

case 1:

cout<<"Hello";

case 2:

cout<<"world";

case 3:

cout<<"End";

} return 0;

}

Options:

A.

It prints: Hello


B.

It prints: world


C.

It prints: worldEnd


D.

It prints: End


Expert Solution
Viewing page 4 out of 8 pages
Viewing questions 31-40 out of questions