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
    :Jan 13, 2026

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

  • Question 1:

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

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

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

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

    pair::iterator,set::iterator> range;

    range = s1.equal_range(6);

    cout<<*range.first<<" "<<*range.second<

    return 0;

    }

    The output will be:

    A. 6 6
    B. 5 7
    C. 6 7
    D. 1 5
    E. 6 5

  • Question 3:

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

    #include

    #include

    #include

    using namespace std;

    void print(int v) { cout<

    struct Sequence {

    int start;

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

    int operator()() {

    return 10*(1+(start++ %3));

    }

    };

    int main() {

    vector v1(10);

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

    remove(v1.begin(), v1.end(), 10);

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

    return 0;

    }

    Program outputs:

    A. 20 30 10 20 30 10 20 30 10 20
    B. 20 30 20 30 20 30 20
    C. 20 30 20 30 20 30 20 30 10 20
    D. compilation error

  • Question 4:

    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(), 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 5:

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

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

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

    #include

    #include

    #include

    using namespace std;

    template

    int calculate(T start, T end)

    {

    int s = 0;

    while (start != end)

    s+= *start; start++;return s;

    }

    int main ()

    {

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

    vectorv1(t, t+5);

    dequed1(t+5, t+10);

    cout<

    cout<

    cout<

    cout<

    cout<

    return 0;

    }

    A. compilation error
    B. runtime exception
    C. program outputs 55 5 17 55
    D. program outputs 55 5 17 0

  • Question 8:

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

    int start;

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

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

    };

    struct Odd { bool operator()(int v) { return v%2==0; } };

    int main() {

    vector v1(10);

    vector v2(10);

    generate(v1.begin(), v1.end(), Sequence(1));

    stable_partition(v1.begin(),v1.end(), Odd());

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

    return 0;

    }

    Program outputs:

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

  • Question 9:

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

    #include

    using namespace std;

    int main()

    {

    cout.setf(ios::oct, ios::basefield);

    cout<<100<<" ";

    cout.setf(ios::showbase);

    cout<<100<<" ";

    return 0;

    }

    Program outputs:

    A. 144 0144
    B. 144 0x64
    C. 0x144 0144
    D. 0144 100
    E. compilation error

  • Question 10:

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

    int start;

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

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

    int main() {

    vector v1(10);

    vector v2(10);

    generate(v1.begin(), v1.end(), Sequence(1));

    random(v1.begin(),v1.end());

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

    return 0;

    }

    Program outputs:

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