Official Bank 0/228

C++ Certified Professional Programmer (CPP) - CPPL Actual Exam Questions

Last updated on May 14, 2026

97% Exam Compliance
228 Total Questions
1
Question

What happens when you attempt to compile and run the following code? #include <list> #include <iostream> using namespace std; template<class T> void print(T start, T end) { while (start != end) { std::cout << *start << " "; start++; } } int main() { int t1[] ={ 1, 7, 8, 4, 5 }; list<int> l1(t1, t1 + 5); int t2[] ={ 3, 2, 6, 9, 0 }; 4XHVWLRQV�DQG�$QVZHUV�3') ������ list<int> l2(t2, t2 + 5); l1.sort(); list<int>::iterator it = l2.begin(); it++; it++; l1.splice(l1.end(),l2, it, l2.end()); print(l1.begin(), l1.end()); cout<<"Size:"<<l1.size()<<" "; print(l2.begin(), l2.end()); cout<<"Size:"<<l2.size()<<endl; return 0; }

Options
A

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

B

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

C

compilation error

D

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

E

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

Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

2
Question

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; template<class A> void f(A &a) { cout<<1<<endl; } void f(int &a) { cout<<2<<endl; } int main() { int a = 1; f(a); return 0; }

Options
A

program displays: 1

B

program displays: 2

C

compilation error

D

runtime exception 4XHVWLRQV�DQG�$QVZHUV�3') �������

Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

3
Question

4XHVWLRQV�DQG�$QVZHUV�3') ������ What happens when you attempt to compile and run the following code? #include <vector> #include <iostream> #include <algorithm> #include <functional> using namespace std; class B { int val; public: B(int v=0):val(v){} int getV() const {return val;} operator int () const { return val;} }; template<class T>struct Out { ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out<<val<<" "; } }; struct Add : public binary_function<B, B, B> { B operator() (const B & a, const B &

Options
A

1 2 3 4 5 6 7 8 9 10

B

const { return a+b; } }; int main() { B t[]={1,2,3,4,5,6,7,8,9,10}; vector<B> v1(t, t+10); vector<B> v2(10); transform(v1.begin(), v1.end(), v2.begin(), bind1st(Add(), 1)); for_each(v2.rbegin(), v2.rend(), Out<B>(cout));cout<<endl; return 0; } Program outputs:

C

2 3 4 5 6 7 8 9 10 11

D

10 9 8 7 6 5 4 3 2 1

E

11 10 9 8 7 6 5 4 3 2

F

compilation error

Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

4
Question

What happens when you attempt to compile and run the following code? #include <vector> #include <iostream> #include <algorithm> using namespace std; class B { int val; public: B(int v=0):val(v){} int getV() const {return val;} }; ostream & operator <<(ostream & out, const B &

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

F

{ out<<v.getV(); return out;} template<class T>struct Out { ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out<<val<<" "; } }; int main() { B t1[]={3,2,4,1,5}; B t2[]={6,10,8,7,9}; vector<B> v1(5); transform(t1,t1+5,t2,v1.rbegin(), plus<B>()); for_each(v1.rbegin(), v1.rend(), Out<int>(cout));cout<<endl; return 0; } Program outputs:

Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

5
Question

What happens when you attempt to compile and run the following code? #include <iostream> #include <algorithm> #include <vector> using namespace std; void myfunction(int

Select 2
Options
A

{ a*2; } int main() { int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; vector<int> v1(t, t+10); for_each(v1.begin(), v1.end(), multiply); iter_swap(v1.begin(),t+9); for_each(v1.begin(), v1.end(), myfunction); return 0; } Program outputs:

B

1 5 9 6 2 4 7 8 3 1

C

compilation error

D

1 2 3 4 5 6 7 8 9 10

E

10 9 8 7 6 5 4 3 2 1

F

10 5 9 6 2 4 7 8 3 1

G

{ cout << " " << i; } void multiply (int

Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

Finish Practice?

Are you sure you want to finish? This will end your practice session.