Exclusive Black Friday Deal: 70% Off All Exam Bundles! Use coupon code below to unlock your savings! - Ends in 0d 00h 00m 00s - Coupon code: Friday70

Free Beingcert Certified Python Programmer Exam Practice Questions

Question # 21

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

#include

#include

#include

using namespace std;

template void print(T start, T end) {

while (start != end) {

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

}

}

int main(){

vectorv;

set s;

for(int i=10; i>0; i??) {

v.push_back(i);

s.push_back(i);

}

print(v.begin(), v.end()); print(s.begin(), s.end());cout<

return 0;

}

The output will be:

Options:

A.  

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

B.  

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

C.  

10 9 8 7 6 5 4 3 2 1 and unpredictable sequence of number range 1 to 10

D.  

compilation error

Discussion 0
Question # 22

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

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

while(cin.good())

{

string s;

cin>>s;

if (s == "quit") break;

l.push_back(s);

}

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

return 0;

}

Program will output:

Options:

A.  

1 2 3 4

B.  

1 2 3 4 quit

C.  

1

D.  

program runs forever without output

Discussion 0
Question # 23

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

vector v1(10,1);

fill(v1.begin()+2, v1.end()?2,2);

fill_n(v1.begin()+4,2,3);

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

return 0;

}

Program outputs:

Options:

A.  

1 1 2 2 3 3 2 2 1 1

B.  

1 1 2 2 2 2 2 2 1 1

C.  

compilation error

D.  

none of these

Discussion 0
Question # 24

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
Question # 25

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 multiply (int a) {

return a*2;

}

int main() {

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

vector v1(t, t+10);

set s1(t, t+10);

transform(s1.begin(), s1.end(), v1.begin(), multiply);

transform(v1.begin(), v1.end(), s1.begin(), multiply);

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

return 0;

}

Program outputs:

Options:

A.  

20 10 18 12 4 8 14 16 6 2

B.  

2 4 6 8 10 12 14 16 18 20

C.  

4 8 12 16 20 24 28 32 36 40

D.  

compilation error

Discussion 0
Question # 26

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

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

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

B 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(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
Question # 27

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

#include

using namespace std;

class C {

public:

int _c;

C():_c(0){}

C(int c) { _c = c;}

C operator+=(C & b) {

C tmp;

tmp._c = _c+b._c;

return tmp;

}

};

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 b(2);

Aa (5);

Cc;

a.add(c);

cout << a.getV() <

return 0;

}

Options:

A.  

program will display:2

B.  

program will not compile

C.  

program will compile

D.  

program will cause runtime exception

Discussion 0
Question # 28

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;

}

struct sequence {

int val,inc;

sequence(int s, int i):val(s),inc(i){}

int operator()(){

int r = val; val += inc;

return r;

}

};

int main() {

vector v1(10);

fill(v1.begin(), v1.end(), sequence(1,1));

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

return 0;

}

Program outputs:

Options:

A.  

1 2 3 4 5 6 7 8 9 10

B.  

10

C.  

0 0 0 0 0 0 0 0 0 0

D.  

compilation error

Discussion 0
Question # 29

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<

}

};

struct Sequence {

int start;

Sequence(int start):start(start){}

int operator()() { return start++; }

};

struct Odd { bool operator()(int v) { return v%2==0; }};

int main() {

vector v1(10);

generate(v1.begin(), v1.end(), Sequence(1));

partition(v1.begin(),v1.end(), Odd());

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

return 0;

}

Choose all possible outputs:

Options:

A.  

1 2 3 4 5 6 7 8 9 10

B.  

5 7 3 9 1 10 2 8 4 6

C.  

10 2 8 4 6 5 7 3 9 1

D.  

4 6 8 10 2 7 5 3 1 9

E.  

2 4 6 8 10 1 3 5 7 9

Discussion 0
Question # 30

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

#include

#include

#include

using namespace std;

int main(){

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

listv(t, t+10);

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

if (s1.count(3) == 2) {

s1.erase(3);

}

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

cout<<*i<<" ";

}

return 0;

}

Options:

A.  

program outputs: 1 2 3 4 5

B.  

program outputs: 1 2 4 5

C.  

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

D.  

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

E.  

compilation error

Discussion 0

CPP PDF

CPP PDF (Printable)
$180
$600

CPP Testing Engine

CPP PDF (Printable)
$180
$600

CPP PDF + Testing Engine

CPP PDF (Printable)

Free Exams Sample Questions

  • We Accept

    exams4sure payments accept


    Secure Site

    mcafee secure

    TESTED 20 Nov 2026

  • Customer Review

    I was overwhelmed by the amount of material I had to cover, but Exams4sure's practice questions were incredibly close to the real exam. I studied for three weeks and passed with confidence. Highly recommend it to anyone short on time!

    exams4sure customer reviews
    Ivy Rose Happy Customer
  • Quality Commitment

    We don't just sell practice tests, we deliver results. Our material is carefully crafted to cover exactly what you need, so even with a tight schedule, you can prepare effectively and pass with confidence. If it doesn't meet your expectations, we're only a message away, your success and satisfaction come first.