Black Friday Special 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: save70

Pass Using CPP Exam Dumps

Page: 4 / 9
Total 228 questions

C++ Certified Professional Programmer Questions and Answers

Question 13

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

#include

using namespace std;

void g(int a)

{

cout<<a?1<

}

template

void g(A a)

{

cout<<a+1<

}

int main()

{

int a = 1;

g(a);

return 0;

}

Options:

A.

program displays: 0

B.

program displays: 2

C.

compilation error

D.

runtime exception

Question 14

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

#include

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) { out<

int main() {

int t1[]={3,2,4,1,5};

int t2[]={6,10,8,7,9};

vector v1(5);

transform(t1,t1+5,t2,v1.rbegin(), plus());

for_each(v1.rbegin(), v1.rend(), Out(cout));cout<<endl;

return 0;

}

Program outputs:

Options:

A.

9 12 12 8 14

B.

14 8 12 12 9

C.

3 2 4 1 5 6 10 8 7 9

D.

1 2 3 4 5 6 7 8 9 10

E.

compilation error

Question 15

What will happen when you attempt to compile and run the code below, assuming you enter the following sequence: 1 2 3?

#include

using namespace std;

int main ()

{

int a,b,c;

cin>>a>>b>>c;

cout<<a<

return 0;

}

Program will output:

Options:

A.

123

B.

1 2 3

C.

321

D.

compilation error

E.

the result is unspecified

Question 16

What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: 1 2 3 end?

#include

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) {out<

int main ()

{

list l;

for( ; !cin.bad() ; )

{

int i;

cin>>i;

l.push_back(i);

}

for_each(l.begin(), l.end(), Out(cout));

return 0;

}

Program will output:

Options:

A.

1 2 3

B.

1 2 3 end

C.

1

D.

compilation error

E.

program runs forever without output

Page: 4 / 9
Total 228 questions