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

    Which stack initialization (line numbers) are correct? Choose all that apply.

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    int main()

    {

    deque mydeck;

    list mylist;

    vector myvector;

    stack first;// Line I

    stack second(mydeck);// Line II

    stack third(second);// Line III

    stack > fourth(mylist);// Line IV

    stack > fifth(myvector);// Line V

    return 0;

    }

    A. line I
    B. line II
    C. line III
    D. line IV
    E. line V

  • Question 172:

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

    deque d1(t, t+10);

    deque::iterator it = lower_bound(d1.begin(), d1.end(), 4);

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

    return 0;

    }

    Program outputs:

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

  • Question 173:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    int main(){

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

    vector v(t, t+10);

    map m;

    for(vector::iterator i=v.begin(); i!=v.end(); i++) {

    stringstream s; s<<*i<<*i; m.insert(pair(*i,s.str()));

    }

    for(map::iterator i=m.begin();i!= m.end(); i++) {

    cout<<*i<<" ";

    }

    return 0;

    }

    A. program outputs: 3 4 2 1 6 5 7 9 8 0
    B. program outputs: 00 11 22 33 44 55 66 77 88 99
    C. program outputs: 0 1 2 3 4 5 6 7 8 9
    D. program outputs: 0 00 1 11 2 22 3 33 4 44 5 55 6 66 7 77 8 88 9 99
    E. compilation error

  • Question 174:

    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<

    B Add(B a, B b) { 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(), bind2nd(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 175:

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

    #include

    #include

    using namespace std;

    template

    class A {

    T_v;

    public:

    A() {}

    A(T v): _v(v){}

    T getV() { return _v; }

    void add(T and a);

    void add(string and a);

    };

    template

    void A::add(T and a) { _v+=a; }

    void A::add(string and a) {

    _v.insert(0, a);

    }

    int main()

    {

    Aa("Hello");

    string s(" world!");

    a.add(s);

    cout << a.getV() <

    return 0;

    }

    A. program will display: Hello world!
    B. compilation error
    C. program will display: world!Hello
    D. program will run without any output

  • Question 176:

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

    vectorv1(t, t+5);

    listl1;

    l1.assign(v1.end(), v1.begin());

    for(int i=0; i

    {

    cout<

    }

    cout<

    return 0;

    }

    A. program displays 5 4 3 2 1
    B. program displays 1 2 3 4 5
    C. compilation error
    D. segmentation fault runtime exception

  • Question 177:

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

    #include

    #include

    using namespace std;

    int main ()

    {

    string a;

    cin>>a;

    cout<

    return 0;

    }

    Program will output:

    A. one
    B. one two three
    C. runtime exception
    D. compilation error
    E. the result is unspecified

  • Question 178:

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

    #include

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

    vector v1(t, t + 10);

    deque d1(t, t + 10);

    set s1(t, t + 10);

    for_each(v1.begin(), v1.end(), myfunction); // Line I

    for_each(d1.begin(), d1.end(), myfunction); // Line II

    for_each(s1.begin(), s1.end(), myfunction); // Line III return 0;

    }

    A. program outputs: 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 1 2 3 4 5 6 7 8 9 10
    B. program outputs: 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1
    C. program outputs: 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
    D. compilation error in line I
    E. compilation error in line III

  • Question 179:

    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=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 {

    B operator()(B and a, B and b) { 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(1,Add()));

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

    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_backward(t, t+10, v1.rend());

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

    return 0;

    }

    Program outputs:

    A. 10 5 9 6 2 4 7 8 3 1
    B. 1 3 8 7 4 2 6 9 5 10 10 5 9 6 2 4 7 8 3 1
    C. 1 3 8 7 4 2 6 9 5 10
    D. runtime exception/segmentation fault
    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.