CPP-22-02 Exam Details

  • Exam Code
    :CPP-22-02
  • Exam Name
    :CPP - C++ Certified Professional Programmer
  • Certification
    :C++ Institute Certifications
  • Vendor
    :C++ Institute
  • Total Questions
    :228 Q&As
  • Last Updated
    :Jul 15, 2026

C++ Institute CPP-22-02 Online Questions & Answers

  • Question 81:

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

    vectorv(t, t+10);

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

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

    pair::iterator,multiset::iterator> range;

    range = s1.equal_range(6);

    while (range.first != range.second) {

    cout<<*range.first<<" "; range.first++;

    }

    return 0;

    }

    A. program outputs: 6 6
    B. program outputs: 5 7
    C. program outputs: 5 5 6 6 7 7
    D. program outputs: 5 5 7 7
    E. program outputs: 1 1 6 6 5 5

  • Question 82:

    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;

    }

    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

  • Question 83:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    class compare {

    bool reverse;

    public:

    compare(bool revparam = false){ reverse = revparam;}

    bool operator()(int lhs, int rhs) const{

    if (reverse)return (lhs > rhs);

    elsereturn (lhs < rhs);

    }

    };

    int main(){

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

    priority_queue > first(myints, myints + 10);

    priority_queue, compare> second(myints, myints + 10,

    compare(false));

    while (first.size() > 0){

    cout << first.top() << " "; first.pop();

    }

    while (second.size() > 0) {

    cout << second.top() << " ";second.pop();

    }

    return 0;

    }

    A. compilation error
    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: 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9
    D. program outputs: 3 4 2 1 6 5 7 9 8 0 3 4 2 1 6 5 7 9 8 0

  • Question 84:

    Which changes, introduced independently, will allow the code to compile and display "one" "eight" "nine" "ten"? Choose all that apply

    #include

    #include

    #include

    using namespace std;

    class A {

    int a;

    public:

    A(int a):a(a){}

    int getA() const { return a;}

    /* Insert Code Here 1 */

    };

    /* Insert Code Here 2 */

    int main(){

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

    string s[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","ten"}; map m;/* Replace Code Here 3 */

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

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

    }

    m.erase(m.lower_bound(2),m.upper_bound(7));

    map::iterator i=m.begin(); /* Replace Code Here 4 */

    for( ;i!= m.end(); i++) {

    cout<second<<" ";

    }

    cout<

    return 0;

    }

    A. operator int() const { return a;} inserted at Place 1
    B. bool operator < (const A and b) const { return a
    C. bool operator < (const A and b) const { return b.a
    D. struct R { bool operator ()(const A and a, const A and b) { return a.getA()

  • Question 85:

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

    #include

    #include

    #include

    using namespace std;

    int main ()

    {

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

    dequed1(t, t+10);

    vectorv1(t, t+10);

    cout<

    cout<

    d1.resize(12); v1.resize(12);

    cout<

    cout<

    d1.reserve(20);v1.reserve(20);

    cout<

    cout<

    return 0;

    }

    A. the output is 10 10 10 10 12 12 12 12 20 20
    B. reserve and resize means exactly the same
    C. there are compilation errors
    D. capacity is always smaller then size

  • Question 86:

    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 and out;

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

    void operator() (const T and 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:

    A. 1 2 3
    B. 1 2 3 end
    C. 1
    D. compilation error
    E. program runs forever without output

  • Question 87:

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

    #include

    #include

    #include

    using namespace std;

    templatestruct Out {

    ostream and out;

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

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

    int main() {

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

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

    vector v1(10);

    sort(t1, t1+5);

    sort(t2, t2+5);

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

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

    return 0;

    }

    Program outputs:

    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

  • Question 88:

    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 ,4 ,5, 6 , 7, 8 , 9, 10};

    vectorv1(t, t+10);

    dequed1(t, t+10);

    d1.empty();

    v1.empty();

    if (v1.isempty())

    {

    cout<<"I am empty ";

    }

    else

    {

    cout<<"I am not empty ";

    }

    cout<

    return 0;

    }

    A. program outputs: I am empty 0 0
    B. program outputs: I am not empty 0 0
    C. compilation error
    D. program outputs: I am not empty 10 10

  • Question 89:

    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, 7, 8, 4, 5 };

    list l1(t1, t1 + 5);

    int t2[] ={ 3, 2, 6, 9, 0 };

    list l2(t2, t2 + 5);

    l1.sort();

    list::iterator it = l2.begin();

    it++; it++;

    l1.splice(l1.end(),l2, it, l2.end());

    print(l1.begin(), l1.end()); cout<<"Size:"<

    print(l2.begin(), l2.end()); cout<<"Size:"<

    return 0;

    }

    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

  • Question 90:

    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 and v) const { return val>v.val;} };

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

    templatestruct Out {

    ostream and out;

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

    void operator() (const T and 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 0;

    }

    Program outputs:

    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. 5 2 1 0 0 0 0 0 0 0
    E. 1 2 5 0 0 0 0 0 0 0

Tips on How to Prepare for the Exams

Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPP-22-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.