Summer Sale Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: ecus65

C++ Institute CPA-21-02 - CPA - C++ Certified Associate Programmer

Page: 8 / 8
Total 257 questions

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

#include

using namespace std;

int min(int a, int b);

int main()

{

int b=10;

b = min(5,20);

cout << b;

return 0;

}

int min(int a, int b)

{

if (a

return(a);

else

return(b);

}

A.

It prints: 10

B.

It prints: 20

C.

It prints: 5

D.

It prints: 0

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

#include

using namespace std;

void fun(char*);

int main()

{

char t[4]={'0', '1', '2', '3'};

fun(&t[0]);

return 0;

}

void fun(char *a)

{

cout << *a;

}

A.

It prints: 01

B.

It prints: 1

C.

It prints: 0

D.

It prints: 0123

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

#include

#include

using namespace std;

class Second;

class Base {

int age;

public:

Base () { age=5; };

friend void set(Base &ob, Second &so);

void Print() { cout << age;}

};

class Second {

string name;

public:

friend void set(Base &ob, Second &so);

void Print() { cout << name;}

};

void set(Base &ob, Second &so) {

ob.age = 0; so.name = "Bill";

}

int main () {

Base a;

Second b;

set(a,b);

a.Print();

b.Print();

return 0;

}

A.

It prints: 0Bill

B.

Compilation error

C.

It prints: Bill0

D.

None of these

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

#include

using namespace std;

int main()

{

const char *s;

char str[] = "Hello";

s = str;

while(*s) {

cout << *s++;

}

return 0;

}

A.

It prints: el

B.

It prints: Hello

C.

It prints: H

D.

It prints: o

What will the variable "y" be in class B?

class A {

int x;

protected:

int y;

public:

int age;

};

class B : protected A {

string name;

public:

void Print() {

cout << name << age;

}

};

A.

public

B.

private

C.

protected

D.

None of these

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;

}

A.

It prints: 2

B.

It prints: 28

C.

It prints: 8

D.

It prints: 6

A condition expression used by if(), while(), and do-while() must evaluate to and only to:

A.

an int type value

B.

any value that can be treated as truth/falsehood

C.

a float type value

D.

a bool type value