Weekend Special Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: scxmas70

Note! Following CPA Exam is Retired now. Please select the alternative replacement for your Exam Certification. The new exam code is CPA-21-02

CPA Exam Dumps - C++ Certified Associate Programmer

Go to page:
Question # 25

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;

}

A.

It prints: 4

B.

It prints: 6

C.

It prints: 3

D.

It prints: 0

Full Access
Question # 26

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

#include

using namespace std;

int x=5;

static int y;

int i=0;

void static myFunction()

{

y=x++ + ++i;

}

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

{

x++;

myFunction();

cout<

}

A.

Compilation fails

B.

It prints: 5 5 0

C.

It prints: 7 7 1

D.

It prints: 6 5 1

Full Access
Question # 27

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

#include

using namespace std;

class complex{

double re;

double im;

public:

complex() : re(0),im(0) {}

complex(double x) { re=x,im=x;};

complex(double x,double y) { re=x,im=y;}

void print() { cout << re << " " << im;}

};

int main(){

complex c1(1,2);

c1.print();

return 0;

}

A.

It prints: 1 0

B.

It prints: 1 1

C.

It prints: 1 2

D.

Compilation error

Full Access
Question # 28

What will the variable "age" 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

Full Access
Question # 29

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

#include

using namespace std;

class complex{

double re;

double im;

public:

complex() : re(0),im(0) {}

complex(double x) { re=x,im=x;};

complex(double x,double y) { re=x,im=y;}

void print() { cout << re << " " << im;}

};

int main(){

complex c1;

double i=2;

c1 = i;

c1.print();

return 0;

}

A.

It prints: 0 0

B.

It prints: 1 1

C.

It prints: 2 0

D.

It prints: 2 2

Full Access
Question # 30

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

#include

using namespace std;

int op(int x, int y);

int main()

{

float *pf;

float f=0.9;

pf=&f;

cout << op(1, *pf);

return 0;

}

int op(int x, int y)

{

return x*y;

}

A.

It prints: 0

B.

It prints: 0.5

C.

It prints: 1

D.

It prints: ?1

Full Access
Question # 31

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

#include

using namespace std;

namespace myNamespace1

{

int x = 5;

int y = 10;

}

namespace myNamespace2

{

float x = 3.14;

float y = 1.5;

}

int main () {

{

using namespace myNamespace1;

cout << x << " ";

}{

using namespace myNamespace2;

cout << y;

}

return 0;

}

A.

It prints: 5 1.5

B.

It prints: 3.14 10

C.

Compilation error

D.

None of these

Full Access
Question # 32

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

#include

using namespace std;

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

char *s = "ABCDEF";

cout << s+2;

return 0;

}

A.

It prints: CDEF

B.

It prints: ABCDEF

C.

It prints: BCDEF

D.

None of these

Full Access
Go to page: