Weekend Sale 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: exams65

ExamsBrite Dumps

C++ Certified Professional Programmer Question and Answers

C++ Certified Professional Programmer

Last Update Sep 13, 2025
Total Questions : 228

We are offering FREE CPP C++ Institute exam questions. All you do is to just go and sign up. Give your details, prepare CPP free exam questions and then go for complete pool of C++ Certified Professional Programmer test questions that will help you more.

CPP pdf

CPP PDF

$36.75  $104.99
CPP Engine

CPP Testing Engine

$43.75  $124.99
CPP PDF + Engine

CPP PDF + Testing Engine

$57.75  $164.99
Questions 1

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

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v):val(v){}

int getV() const {return val;} bool operator < (const B & v) const { return val

ostream & operator <<(ostream & out, const B & v) { out<

templatestruct Out {

ostream & out;

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

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

int main() {

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

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

vector v1(10,0);

sort(t1, t1+5); sort(t2, t2+5);

copy(t1,t1+5,v1.begin());

copy(t2,t2+5,v1.begin()+5);

inplace_merge(v1.begin(), v1.begin()+5,v1.end());

for_each(v1.begin(), v1.end(), Out(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

1 2 3 4 5 6 10 8 7 9

B.  

3 2 4 1 5 6 7 8 9 10

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

Discussion 0
Questions 2

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; }

};

struct Even {

bool operator ()(const A & a, const A &b) {

return (a.getA() % 2)==b.getA() % 2;

}

};

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

deque::iterator it = search_n(d.begin(), d.end(), 3, 2, Even());

cout<< it?d.begin()<

return 0;

}

Program outputs:

Options:

A.  

compilation error

B.  

12

C.  

3

D.  

1

E.  

15

Discussion 0
Questions 3

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

string t[]={"aaa","Aaa", "aAa","aaA","bbb","Bbb", "bBb", "bbB"};

vector v1(t, t+8);

sort(v1.begin(), v1.end());

for_each(v1.begin(), v1.end(), Out(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

Aaa Bbb aAa aaA aaa bBb bbB bbb

B.  

Aaa aAa Bbb aaA aaa bBb bbB bbb

C.  

bBb bbB bbb Aaa aAa Bbb aaA aaa

D.  

Aaa aAa bBb bbB bbb Bbb aaA aaa

E.  

compilation error

Discussion 0
Questions 4

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

#include

#include

#include

using namespace std;

int main(){

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

multiset s1(t,t+10);

s1.insert(s1.find(7), 3);

for(multiset::iterator i=s1.begin();i!= s1.end(); i++) {

cout<<*i<<" ";

}

return 0;

}

Options:

A.  

program outputs: 0 1 2 3 3 4 5 6 7 8 9

B.  

program outputs: 0 1 2 3 4 5 6 7 8 9

C.  

program outputs: 0 1 2 3 4 5 6 7 3 8 9

D.  

program outputs: 0 1 2 3 4 5 6 3 7 8 9

E.  

runtime exception

Discussion 0
Questions 5

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

#include

#include

#include

using namespace std;

bool compare(int a, int b) { return a == b; }

int main () {

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

vector v (t,t+10);

vector::iterator it = v.begin();

int m1[] = {1, 2, 3};

while ( (it = find_first_of (it, v.end(), m1, m1+3)) != v.end()) {

cout<

}

cout<< endl;

return 0;

}

Options:

A.  

program outputs: 0 1 2 5 6 7

B.  

program outputs: 0 5

C.  

program outputs: 0 0

D.  

compilation error

E.  

program will run forever

Discussion 0
Questions 6

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

#include

#include

#include

using namespace std;

int main(){

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

vectorv(myints, myints+10);

set s1(v.begin(),v.end());

set > s2(v.begin(), v.end());

for(set::iterator i=s1.begin();i!= s1.end(); i++) {

cout<<*i<<" ";

}

for(set >::iterator i=s2.begin();i!= s2.end(); i++) {

cout<<*i<<" ";

}

cout<

return 0;

}

Options:

A.  

program outputs: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9

B.  

program outputs: 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0

C.  

program outputs: 0 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 0

D.  

program outputs: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9

Discussion 0
Questions 7

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

#include

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v):val(v){}

int getV() const {return val;} bool operator < (const B & v) const { return val

};

ostream & operator <<(ostream & out, const B & v) { out<

templatestruct Out {

ostream & out;

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

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

};

int main() {

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

B t1[]={B(1),B(2),B(3),B(4)};

deque d1(t, t+10);

set s1(t, t+10);

sort(d1.begin(), d1.end());

cout<

<

return 0;

}

Program outputs:

Options:

A.  

1 1

B.  

1 0

C.  

0 1

D.  

0 0

E.  

compilation error

Discussion 0
Questions 8

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

#include

#include

using namespace std;

class A

{

int a,b;

public:

A(const A & c) { a = c.a; }

A():a(0),b(0){}

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

int getA() {return a;} int getB() {return b;}

};

int main ()

{

vectorv;

A a;

a.setA(10); a.setB(11);

v.push_back(a);

cout<

return 0;

}

Options:

A.  

program outputs 10 11

B.  

the result is unpredictable

C.  

program outputs 10 0

D.  

program outputs 11 0

E.  

compilation error

Questions 9

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 t[]={3,2,4,1,5,6,10,8,7,9};

vector v1(t, t+10);

for_each(v1.begin(), v1.end(), bind1st(plus(), 1));

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

return 0;

}

Program outputs:

Options:

A.  

3 2 4 1 5 6 10 8 7 9

B.  

4 3 5 2 6 7 11 9 8 10

C.  

9 7 8 10 6 5 1 4 2 3

D.  

10 8 9 11 7 6 2 5 3 4

E.  

compilation error

Discussion 0
Questions 10

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

#include

#include

using namespace std;

int main() {

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

string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"};

multimap m;

for (int i = 0; i < 10; i++) {

m.push_back(pair(t[i], s[i]));

}

for (multimap::iterator i = m.begin(); i != m.end(); i++) {

cout << i?>first << " ";

}

return 0;

}

Options:

A.  

program outputs: 1 2 3 4 5

B.  

compilation error

C.  

program outputs: 1 1 2 2 3 3 4 4 5 5

D.  

program outputs: one two three four five

E.  

program outputs: one one two two three three four four five five

Discussion 0
Questions 11

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

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

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

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

int main() {

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

deque d1(t, t+10);

sort(d1.begin(), d1.end());

deque::iterator it = upper_bound(d1.begin(), d1.end(), 4);

for_each(it, d1.end(), Out(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

5 6 7 8 9 10

B.  

4 5 6 7 8 9 10

C.  

1 2 3 4 5 6 7 8 9 10

D.  

1 2 3 4 5

E.  

1 2 3 4

Discussion 0
Questions 12

What will happen when you attempt to compile and run the following code? Choose all possible answers.

#include

using namespace std;

class B {};

template

class A {

T_v;

public:

A() {}

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

T getV() { return _v; }

void add(T a) { _v+=a; }

};

int main()

{

A a(1);

Ab;

a.add(10);

cout << a.getV() <

return 0;

}

Options:

A.  

program will display:11

B.  

program will not compile

C.  

program will compile

D.  

program will cause runtime exception

Discussion 0
Questions 13

What happens when you attempt to compile and run the following code? Choose all that apply.

#include

#include

#include

using namespace std;

class A

{

int a;

public:

A(int a) {this?>a = a; c++;}

A(const A & a) {this?>a = a.a; c++;}

~A() { c??;}

static int c;

};

int A::c(0);

int main ()

{

A* t[] = {new A(1), new A(2), new A(3),new A(4), new A(5)};

vectorv1(t, t+10);

dequed1(v1.begin(), v1.end());

d1.clear();

v1.clear();

cout<

return 0;

}

Options:

A.  

there are 15 A objects created,

B.  

there are 5 A objects created,

C.  

for all object A the destructor is called

D.  

program will display 5

Discussion 0
Questions 14

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

#include

#include

using namespace std;

template

void print(T start, T end) {

while (start != end) {

std::cout << *start << " "; start++;

}

}

int main()

{

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

list l1(t1, t1 + 5);

l1.remove(2);

print(l1.begin(), l1.end()); cout<

return 0;

}

Options:

A.  

program outputs: 1 2 4 5

B.  

program outputs: 3 4 5

C.  

program outputs: 1 3 4 5

D.  

program outputs: 4 5

Discussion 0
Questions 15

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

#include

using namespace std;

template

class A {

T_v;

public:

A() {}

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

friend ostream & operator<<(ostream & c, const A & v);

};

template

ostream & operator<<(ostream & c, const A & v) {

c<

int main()

{

Aa(10);

cout<

return 0;

}

Options:

A.  

program will display:10

B.  

program will not compile

C.  

program will compile

D.  

program will run without output

Discussion 0
Questions 16

What happens when you attempt to compile and run the following code? Choose all that apply.

#include

#include

#include

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v=0):val(v){}

int getV() const {return val;}

operator int() const { return val; };};

templatestruct Out {

ostream & out;

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

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

int main () {

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

fstream f("test.out", ios::trunc|ios::out);

list l(t, t+10);

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

f.close();

f.open("test.out");

for( ; f.good() ; ) {

int i;

f>>i;

cout<

}

f.close();

return 0;

}

Options:

A.  

file test.out will be opened writing

B.  

file test.out will be truncated

C.  

file test.out will be opened for reading

D.  

no file will be created nor opened

E.  

program will display sequence 1 2 3 4 5 6 7 8 9 10

Discussion 0
Questions 17

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

#include

#include

#include

using namespace std;

int main () {

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

vector v (t,t+15);

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

cout<< number<

return 0;

}

Program outputs:

Options:

A.  

4

B.  

3

C.  

2

D.  

0

E.  

compilation error

Discussion 0
Questions 18

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 };

deque d1(t, t+10);

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

sort(d1.begin(), d1.end());

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

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

for_each(d1.begin(), d1.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 1 3 8 7 4 2 6 9 5 10

E.  

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

Discussion 0
Questions 19

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

#include

#include

#include

using namespace std;

int main () {

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

vector v (t,t+15);

vector::iterator it = search_n(v.begin(), v.end(), 4, 2);

cout<< it?v.begin()<

return 0;

}

Program outputs:

Options:

A.  

10

B.  

3

C.  

1

D.  

15

E.  

compilation error

Discussion 0
Questions 20

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

#include

using namespace std;

int main()

{

cout.setf(ios::hex, ios::basefield);

cout<<100<<" ";

cout.flags(ios::showbase);

cout<<100<<" ";

return 0;

}

Program outputs:

Options:

A.  

64 64

B.  

64 0x64

C.  

0x64 0x64

D.  

64 100

E.  

compilation error

Discussion 0
Questions 21

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

#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[]={5,6,8,2,1};

vector v1(10);

sort(t1, t1+5);

sort(t2, t2+5);

set_intersection(t1,t1+5,t2,t2+5,v1.begin());

for_each(v1.begin(), v1.end(), Out(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

compilation error

B.  

1 2 3 4 5 6 8 0 0 0

C.  

1 2 3 4 5 6 8 2 1 0

D.  

1 1 2 2 3 4 5 5 6 8

E.  

1 2 5 0 0 0 0 0 0 0

Discussion 0
Questions 22

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

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v):val(v){} B(){}

int getV() const {return val;} };

ostream & operator <<(ostream & out, const B & v) { out<

templatestruct Out {

ostream & out;

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

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

int main() {

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

deque d1(t, t+10);

deque::iterator it = lower_bound(d1.begin(), d1.end(), 4);

for_each(it, d1.end(), Out(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

8 10 5 1 4 6 2 7 9 3

B.  

4 5 6 7 8 9 10

C.  

1 2 3 4 5 6 7 8 9 10

D.  

compilation error

E.  

1 2 3 4

Discussion 0
Questions 23

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

#include

#include

#include

#include

using namespace std;

int main(){

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

string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","zero"};

map m;

for(int i=0; i<10; i++) {

m.insert(pair(second[i],first[i]));

}

m[0]="ten";

m.insert(pair(1,"eleven"));

for(map::iterator i=m.begin();i!= m.end(); i++) {

cout<second<<" ";

}

return 0;

}

Options:

A.  

program outputs: zero one two three four five six seven eight nine

B.  

program outputs: ten one two three four five six seven eight nine

C.  

program outputs: zero eleven two three four five six seven eight nine

D.  

program outputs: ten eleven two three four five six seven eight nine

E.  

program outputs: 0 1 2 3 4 5 6 7 8 9

Discussion 0
Questions 24

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

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v=0):val(v){}

int getV() const {return val;}

operator int () const { return val;} };

templatestruct Out {

ostream & out;

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

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

struct Add {

B operator()(B & a, B & b) { return a+b; }};

int main() {

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

vector v1(t, t+10);

vector v2(10);

transform(v1.begin(), v1.end(), v2.begin(), bind1st(1,Add()));

for_each(v2.rbegin(), v2.rend(), Out(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

1 2 3 4 5 6 7 8 9 10

B.  

2 3 4 5 6 7 8 9 10 11

C.  

10 9 8 7 6 5 4 3 2 1

D.  

11 10 9 8 7 6 5 4 3 2

E.  

compilation error

Discussion 0
Questions 25

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 Add(int a, int b) {

return a+b;

}

int main() {

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

vector v1(t, t+10);

vector v2(10);

transform(v1.begin(), v1.end(), v2.begin(), bind2nd(ptr_fun (Add),1));

for_each(v2.rbegin(), v2.rend(), Out(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

1 2 3 4 5 6 7 8 9 10

B.  

2 3 4 5 6 7 8 9 10 11

C.  

10 9 8 7 6 5 4 3 2 1

D.  

11 10 9 8 7 6 5 4 3 2

E.  

compilation error

Discussion 0
Questions 26

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

#include

#include

#include

#include

using namespace std;

int main() {

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

vector v1(t, t + 15);

set s1(t, t + 15);

pair::iterator, vector::iterator > resultSet = mismatch(s1.begin(), s1.end(), v1.begin());

cout<<*resultSet.first<<" "<<*resultSet.second<

return 0;

}

Program outputs:

Options:

A.  

2 4

B.  

4 2

C.  

0 5

D.  

compilation error

Discussion 0
Questions 27

What will happen when you attempt to compile and run the code below, assuming that file test.in contains the following sequence: 1 2 3?

#include

#include

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

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

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

int main () {

ifstream f("test.in");

list l;

for( ; f.good() ; ) {

int i;

f>>i;

l.push_back(i);

}

f.close();

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

return 0;

}

Program will output:

Options:

A.  

1 2 3

B.  

1 2 3 3

C.  

no output

D.  

compilation error

E.  

program runs forever without output

Discussion 0
Questions 28

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

#include

#include

#include

#include

using namespace std;

bool identical(int a, int b) {

return b == 2*a?true:false;

}

int main() {

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

int u[] = {2,4,6,4,6,10,2,4,14,6,4,2,20,8,8,5};

vector v1(t, t + 15);

deque d1(u, u + 15);

pair::iterator, vector::iterator > result;

result = mismatch(d1.begin(), d1.end(), v1.begin(), identical); //Line I

if (result.first == d1.end() && result.second == v1.end()) {//Line II

cout<<"Identical\n";

} else {

cout<<"Not identical\n";

}

return 0;

}

Program outputs:

Options:

A.  

Identical

B.  

Not identical

C.  

compilation error at line marked I

D.  

compilation error at line marked II

Discussion 0
Questions 29

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

#include

#include

#include

#include

#include

using namespace std;

int main(){

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

vector v(t, t+10);

multimap m;

for(vector::iterator i=v.begin(); i!=v.end(); i++) {

stringstream s; s<<*i<<*i; m.insert(pair(*i,s.str()));

}

for(multimap::iterator i=m.begin();i!= m.end(); i++) {

cout<<*i<<" ";

}

return 0;

}

Options:

A.  

program outputs: 3 4 2 1 0 1 2 3 4 0

B.  

program outputs: 00 11 22 33 44

C.  

program outputs: 0 0 1 1 2 2 3 3 4 4

D.  

program outputs: 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4

E.  

compilation error

Discussion 0
Questions 30

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

#include

#include

#include

#include

#include

using namespace std;

int main(){

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

vector v(t, t+10);

map m;

for(vector::iterator i=v.begin(); i!=v.end(); i++) {

stringstream s; s<<*i<<*i; m.insert(pair(*i,s.str()));

}

for(map::iterator i=m.begin();i!= m.end(); i++) {

cout<<*i<<" ";

}

return 0;

}

Options:

A.  

program outputs: 3 4 2 1 6 5 7 9 8 0

B.  

program outputs: 00 11 22 33 44 55 66 77 88 99

C.  

program outputs: 0 1 2 3 4 5 6 7 8 9

D.  

program outputs: 0 00 1 11 2 22 3 33 4 44 5 55 6 66 7 77 8 88 9 99

E.  

compilation error

Discussion 0
Questions 31

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

#include

#include

#include

using namespace std;

int main(){

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

vectorv(t, t+10);

set s1(v.begin(),v.end());

s1.insert(v.begin(),v.end());

bool found = s1.find(7);

if (found){

cout<<"Element found!\n";

}else {

cout<<"Element not found!\n";

}

return 0;

}

Options:

A.  

program will display "Element found!"

B.  

program will display "Element not found!\n"

C.  

code will not compile

D.  

changing type of variable found to int will make this code compile

Discussion 0
Questions 32

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<

template struct Sequence {

T start; T step;

Sequence(T start, T step):start(start), step(step){}

T operator()() { T v = start; start+=step; return v; } };

bool Less(float a, float b) { return int(a)

int main() {

float t[]={2.28, 1.66, 1.32, 3.94, 3.64, 2.3, 2.98, 1.96, 2.62, 1.13};

vector v1; v1.assign(t, t+10);

stable_sort(v1.begin(), v1.end(), Less);

for_each(v1.begin(), v1.end(), Out(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

1.66 1.32 1.96 1.13 2.28 2.3 2.98 2.62 3.94 3.64

B.  

1.13 1.32 1.66 1.96 2.28 2.3 2.62 2.98 3.64 3.94

C.  

compilation error

D.  

3.94 3.64 2.98 2.62 2.3 2.28 1.96 1.66 1.32 1.13

E.  

the exact output is impossible to determine

Discussion 0
Questions 33

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

#include

#include

#include

#include

#include

using namespace std;

int main()

{

deque mydeck;list mylist; vector myvector;

stack first;

stack second(mydeck);

stack third(second);

stack > fourth(mylist);

fourth.push(10);fourth.push(11);fourth.push(12);

stack > fifth(myvector);

fifth.push(10);fifth.push(11);fifth.push(12);

while(!fifth.empty())

{

cout<

fifth.pop();

}

while (!fourth.empty())

{

cout << fourth.front() << " ";

fourth.pop();

}

return 0;

}

Options:

A.  

program outputs: 12 11 10 12 11 10

B.  

compilation error

C.  

program outputs: 10 11 12 10 11 12

D.  

runtime exception

Discussion 0
Questions 34

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 t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};

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

deque d1(t, t+10);

set s1(t, t+10);

sort(d1.begin(), d1.end());

cout<

<

return 0;

}

Program outputs:

Options:

A.  

1 1

B.  

1 0

C.  

0 1

D.  

0 0

Discussion 0