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

CPP Exam Dumps - C++ Institute C++ Certified Professional Programmer Questions and Answers

Page: 1 / 8
Questions 4

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

#include

#include

#include

#include

using namespace std;

void myfunction(int i) {

cout << " " << i;

}

int main() {

int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };

set s1(t, t+10);

vector v1(s1.rbegin(), s1.rend());

swap_ranges(s1.begin(), s1.end(), v1.begin());

for_each(v1.begin(), v1.end(), myfunction);

for_each(s1.begin(), s1.end(), myfunction);

return 0;

}

Program outputs:

Options:

A.

10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10

B.

compilation error

C.

1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

D.

1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1

E.

10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1

Buy Now
Questions 5

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

#include

#include

#include

using namespace std;

class A {

int a;

public:

A(int a) : a(a) {}

int getA() const { return a; } void setA(int a) { this?>a = a; }

};

int main () {

int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};

deque d (t,t+15);

int number = count(d.begin(), d.end(), 2);

cout<< number<<endl;

return 0;

}

Program outputs:

Options:

A.

4

B.

3

C.

2

D.

0

E.

compilation error

Buy Now
Questions 6

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

#include

using namespace std;

template

class A {

T_v;

public:

A(T v);

};

template

Options:

A.

:A(T v):_v(v) {}

int main()

{

A a(2);

cout<<1<<endl;

return 0;

}

B.

program will display: 1

C.

program will not compile

D.

program will compile

E.

program will cause runtime exception

Buy Now
Questions 7

Which sentence is correct about the code below?

#include

#include

#include

using namespace std;

class A {

int a;

public:

A(int a) : a(a) {}

int getA() const { return a; }

void setA(int a) { this?>a = a; }

/* Insert Code Here */

};

struct add10 { void operator()(A & a) { a.setA(a.getA() + 10); } };

int main() {

int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };

vector v1(t, t + 10);

for_each(v1.begin(), v1.end(), add10());

vector::iterator it = find(v1.begin(), v1.end(), A(7));

cout << it?>getA() << endl;

return 0;

}

Options:

A.

it will compile and print 7

B.

it will not compile

C.

it will compile but the program result is unpredictable

D.

adding code:

bool operator !=(const A & b) const {

if (this?>a != b.a) { return true; } return false; }

at Place 1 will allow the program to compile

Page: 1 / 8
Exam Code: CPP
Exam Name: C++ Certified Professional Programmer
Last Update: May 18, 2024
Questions: 228
CPP pdf

CPP PDF

$28  $80
CPP Engine

CPP Testing Engine

$33.25  $95
CPP PDF + Engine

CPP PDF + Testing Engine

$45.5  $130