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 111:

    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

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

    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(), B(4), greater());

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

    return 0;

    }

    Program outputs:

    A. 5 6 7 8 9 10
    B. 4 5 6 7 8 9 10
    C. compilation error
    D. 1 2 3 4 5
    E. 1 2 3 4

  • Question 112:

    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=0):val(v){}

    int getV() const {return val;}

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

    templatestruct Out {

    ostream and out;

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

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

    struct Add : public binary_function {

    B operator() (const B and a, const B and b) const {

    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(), bind1st(Add(), 1));

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

    return 0;

    }

    Program outputs:

    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

  • Question 113:

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

    vector v1(10);

    sort(t1, t1+5);

    sort(t2, t2+5);

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

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

    return 0;

    }

    Program outputs:

    A. 6 8 3 4 0 0 0 0 0 0
    B. 3 4 0 0 0 0 0 0 0 0
    C. 6 8 0 0 0 0 0 0 0 0
    D. compilation error
    E. 3 4 6 8 0 0 0 0 0 0

  • Question 114:

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

    vector v1(t, t+10);

    set s1(t, t+10);

    replace(v1.begin(), v1.end(), 1, 10);

    replace(s1.begin(), s1.end(), 1, 10);

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

    return 0;

    }

    Program outputs:

    A. 10 5 2 5 2 4 4 3 3 1
    B. 1 10 2 5 2 4 4 3 3 10
    C. compilation error
    D. 10 5 2 5 2 4 4 3 3 10

  • Question 115:

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

    #include

    using namespace std;

    int main ()

    {

    int a,b,c;

    cin>>a>>b>>c;

    cout<

    return 0;

    }

    Program will output:

    A. 123
    B. 1 2 3
    C. 321
    D. compilation error
    E. the result is unspecified

  • Question 116:

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

    set s1(t, t+10);

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

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

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

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

    return 0;

    }

    Program outputs:

    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 10 9 8 7 6 5 4 3 2 1
    E. 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1

  • Question 117:

    Which sentence is correct about the code below? Choose all that apply.

    #include

    #include

    #include

    using namespace std;

    class F {

    int val;

    public:

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

    bool operator() (int v) {

    if (v == val) return true;

    return false;

    }

    };

    int main() {

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

    vector v1(t, t + 10);

    if (find(v1.begin(), v1.end(), 6) == find(v1.begin(), v1.end(), F(6))) {

    cout<<"Found!\n";

    } else {

    cout<<"Not found!\n";

    }

    return 0;

    }

    A. it will compile successfully
    B. it will display Found!
    C. it will display Not found!
    D. it will not compile successfully

  • Question 118:

    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;

    }

    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

  • Question 119:

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

    include

    #include

    #include

    #include

    #include

    using namespace std;

    int main() {

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

    vector v1(t, t + 10);

    deque d1(t, t + 10);

    set s1(t, t + 10);

    cout<

    return 0;

    }

    A. program outputs: 6 6 6
    B. program outputs: 3 3 5
    C. program outputs: 3 6 5
    D. compilation error
    E. none of these

  • Question 120:

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

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

    ostream and out;

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

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

    set s1(t,t+10);

    cout<

    return 0;

    }

    Program outputs:

    A. 1 0
    B. 1 1
    C. 0 0
    D. 0 1
    E. compilation error

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.