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

    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<

    bool Greater(int v1, int v2) { return v1

    int main() {

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

    vector v1(t, t+10);

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

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

    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<

    struct Add {

    int operator()(int and a, int 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(), bind2nd(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 213:

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

    int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20};

    deque d1(t, t+10);

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

    pair ::iterator, deque::iterator > result = equal_range(d1.begin(), d1.end(), B(20), greater());

    for_each(result.first, result.second, Out(cout));cout<

    return 0;

    }

    Program outputs:

    A. 30 30 30 20 20 20 20 10 10 10
    B. 20 20 20 20
    C. 30 20 20 20 10
    D. 20 20 20 20 10
    E. 30 20 20 20 20 10

  • Question 214:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    int main()

    {

    deque mydeck;list mylist; vector myvector;

    stack first;

    stack second(mydeck);

    stack third(second);

    stack > fourth(mylist);

    fourth.push(10);fourth.push(11);fourth.push(12);

    stack > fifth(myvector);

    fifth.push(10);fifth.push(11);fifth.push(12);

    while(!fifth.empty())

    {

    cout<

    fifth.pop();

    }

    while (!fourth.empty())

    {

    cout << fourth.front() << " ";

    fourth.pop();

    }

    return 0;

    }

    A. program outputs: 12 11 10 12 11 10
    B. compilation error
    C. program outputs: 10 11 12 10 11 12
    D. runtime exception

  • Question 215:

    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;

    }

    bool classifier(int v) {

    return v%2==0;

    }

    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(),classifier, 10);

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

    return 0;

    }

    Program outputs:

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

  • Question 216:

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

    #include

    using namespace std;

    template

    void g(int a)

    {

    cout<

    }

    template

    void g(A a)

    {

    cout<

    }

    int main()

    {

    int a = 1;

    g(a);

    return 0;

    }

    A. program displays: 1
    B. program displays: 2
    C. compilation error
    D. runtime exception

  • Question 217:

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

    vector v1(t,t+10);

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

    cout<

    return 0;

    }

    Program outputs:

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

  • Question 218:

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

    deque d1(t, t+10);

    deque d2(10);

    transform(d1.begin(), d1.end(), d2.begin(), bind2nd(Add(), 1));

    for_each(d2.rbegin(), d2.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 219:

    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<

    };

    int main() {

    char s[]={"qwerty"};

    char t1[]={"ert"};

    char t2[]={"ERT"};

    sort(s, s+6);

    cout<

    return 0;

    }

    Program outputs:

    A. 0 0
    B. 0 1
    C. 1 0
    D. 1 1

  • Question 220:

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

    #include

    #include

    #include

    #include

    using namespace std;

    void print(int v) { cout<

    struct Sequence {

    int start;

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

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

    };

    bool predicate(int v) { return v%2==0; }

    int main() {

    vector v1(10);

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

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

    remove_if(s1.begin(), s1.end(), predicate);

    for_each(s1.begin(), s1.end(), print);cout<

    return 0;

    }

    Program outputs:

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