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

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

    #include

    #include

    #include

    using namespace std;

    int main ()

    {

    listl1;

    dequed1;

    for(int i=0; i<5; i++)

    {

    l1.push_back(i);l1.push_front(i);

    d1.push_back(i);d1.push_front(i);

    }

    for(int i=0; i

    {

    cout<

    }

    cout<

    return 0;

    }

    A. program displays 4 4 3 3 2 2 1 1 0 0 0 0 1 1 2 2 3 3 4 4
    B. runtime exception
    C. compilation error due to line 11
    D. compilation error due to line 12
    E. compilation error due to line 16

  • Question 142:

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

    B operator +(const B andb )const { return B(val + b.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<

    template struct Add : public binary_function {

    A operator() (const A and a, const A and b) const { return a+b; }};

    int main() {

    int 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(ptr_fun (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 143:

    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<struct Out {

    ostream and out;

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

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

    int main() {

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

    vector v1(t,t+10);

    sort(v1.begin(), v1.end(), greater());

    cout<<*min_element(v1.begin(), v1.end());

    return 0;

    }

    Program outputs:

    A. 3
    B. 1
    C. 6
    D. 10
    E. compilation error

  • Question 144:

    What will happen 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 };

    sets(myints, myints+10);

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

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

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

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

    cout<<*i<<" ";

    }

    return 0;

    }

    The output will be:

    A. 0 0 1 1 8 8 9 9
    B. 0 1 8 9
    C. 2 3 4 5 6 7
    D. 3 4 9 8 0
    E. 3 3 4 4 9 9 8 8 0 0

  • Question 145:

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

    #include

    #include

    #include

    using namespace std;

    void myfunction(int i) {

    cout << " " << i;

    }

    void multiply (int a) {

    a*2;

    }

    int main() {

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

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

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

  • Question 146:

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

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

    B 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 147:

    What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: 64 100?

    #include

    #include

    #include

    #include

    using namespace std;

    int main ()

    {

    string s;

    getline(cin, s);

    stringstream input(s);

    stringstream output;

    for( ; !input.fail() ; )

    {

    int i;

    input>>hex>>i;

    output<

    }

    cout<

    return 0;

    }

    What will be the result assuming that user will enter following sequence: 64 100:

    A. 64 100
    B. 100 256
    C. 100 256 256
    D. 0x64 0x100
    E. 0x100 0x256 0x256

  • Question 148:

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

    #include

    using namespace std;

    int main()

    {

    cout<

    return 0;

    }

    Program outputs:

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

  • Question 149:

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

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

    struct Sequence {

    int start;

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

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

    int main() {

    vector v1(10);

    generate_n(v1.begin(), 10, Sequence(1));

    random_shuffle(v1.rbegin(), v1.rend());

    sort(v1.begin(), v1.end(), great());

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

    return 0;

    }

    Program outputs:

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

  • Question 150:

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

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

    vector v1(t, t + 10);

    copy(t, t+10, v1.end());

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

    return 0;

    }

    Program outputs:

    A. 10 5 9 6 2 4 7 8 3 1
    B. 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1
    C. compilation error
    D. runtime exception/segmentation fault

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.