Official Bank 0/228

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

Last updated on June 20, 2026

97% Exam Compliance
228 Total Questions
1
Question
What happens when you attempt to compile and run the following code? #include #include < vector› #include
using namespace std;
int main ()
int t|] = (1, 2,3,4,5, 6, 7, 8, 9, 10);
vectorv1(t, t+10);
dequesint>d1(t, t+10);
d1.empty();
v1.empty();
if (v1.isempty())
cout«"I am empty";
}
else
cout«<"I am not empty";
cout< return 0;
Options
A compilation error
B program outputs: I am empty 00
C program outputs: I am not empty 00
D program outputs: I am not empty 10 10
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 < vector> #include #include < deque> #include #include
using namespace std;
templatestruct Out {
ostream & out;
Out(ostream & o): out(o))
void operator ()(const T & val) {
out< }
};
struct Sequence {
int start;
102/153 Sequence(int start): start(start/
int operator()(){
return start++;
};
int main() (
vector int 1(5);
generate(v1.begin(), v1.end(), Sequence(1));
set s1(v1.rbegin(), v1.rend());
deque d1(s1.rbegin(), s1.rend());
reverse(v1.begin(),v1.end());
reverse(s1.begin(), s1.end());
reverse(d1.begin(), d1.end());
for_each(v1.begin(), v1.end(), Outsint>(cout) );
for_each(s1.begin(), s1.end(), Out(cout) );
for_each(d1.begin(), d1.end), Outsint>(cout) );cout< return 0;

Program outputs:
Options
A compilation error
B 543211234512345 B.123451234554321
C 123455432112345
D no output
Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

3
Question
What happens when you attempt to compile and run the following code? #include #include < iostream> #include < algorithm>
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>v.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[] = (5,6,8,2,1);
vector v1(10,0);
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 O;

Program outputs:
Options
A 1250000000
B compilation error
C 1234568210 D.5210000000
D 1234568000
Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

4
Question
Which are NOT valid instantiations of priority_queue object: #include #include #include < list› #include #include
using namespace std;
int main()
deque mydeck;list mylist; vector myvector;
priority_queue > second;//line I| priority_queue> fourth(third);//line IV priority_queue> fifth(myvector.begin(), myvector.end))://line V
Options
A line I|
B line l
C line V
D line Ill
E line IV
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 #include < algorithm> #include < vector> #include ‹set>
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‹set resultSet = equal(s1.begin(), s1.end(), v1.begin());
cout‹‹*resultSet.first<"" «*resultSet.second‹ return 0;

Program outputs:
Options
A 05
B 24
C 42
D compilation error
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.