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

    Which changes introduced independently will allow the code to compile and display "one" "eight" "nine" "ten"? Choose all that apply.

    #include

    #include

    #include

    using namespace std;

    class A {

    int a;

    public:

    A(int a):a(a){}

    int getA() const { return a;}

    /* Insert Code Here 1 */

    };

    /* Insert Code Here 2 */

    int main(){

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

    string s[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","ten"};

    multimap m;/* Replace Code Here 3 */

    for(int i=0; i<10; i++) {

    m.insert(pair(A(t[i]),s[i]));

    }

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

    multimap::iterator i=m.begin();/* Replace Code Here 4 */

    for( ; i!= m.end(); i++) {

    cout<second<<" ";

    }

    cout<

    return 0;

    }

    A. operator int() const { return a;} inserted at Place 1
    B. bool operator < (const A and b) const { return a
    C. bool operator < (const A and b) const { return b.a
    D. struct R { bool operator ()(const A and a, const A and b) { return a.getA()

  • Question 92:

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

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

    deque d1(t, t+10);

    set s1(t,t+10);

    cout<

    return 0;

    }

    Choose all possible outputs (all that apply):

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

  • Question 93:

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

    #include

    #include

    using namespace std;

    int main() {

    int t[] = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };

    string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"};

    multimap m;

    for (int i = 0; i < 10; i++) {

    m.insert(pair(t[i], s[i]));

    }

    if (m.count(3) == 2) {

    m.erase(3);

    }

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

    cout << i?>first << " ";

    }

    return 0;

    }

    A. program outputs: 1 2 3 4 5
    B. program outputs: 1 2 4 5
    C. program outputs: 1 1 2 2 3 4 4 5 5
    D. program outputs: 1 1 2 2 4 4 5 5
    E. program outputs: one two three four five

  • Question 94:

    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(s1, v1);

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

  • Question 95:

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

    #include

    using namespace std;

    int main ()

    {

    std::vectorv1;

    v1.push_back(10);

    return 0;

    }

    A. compilation fails due to error in line 2
    B. compilation fails due to error in line 5
    C. exception is thrown during run time
    D. code compiles and executes successfully

  • Question 96:

    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[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20};

    deque d1(t, t+10);

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

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

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

    return 0;

    }

    Program outputs:

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

  • Question 97:

    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 start++;

    }

    };

    int main() {

    vector v1(10);

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

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

    cout<

    return 0;

    }

    Program outputs:

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

  • Question 98:

    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_intersection(t1,t1+5,t2,t2+5,v1.begin());

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

    return 0;

    }

    Program outputs:

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

  • Question 99:

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

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

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

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

  • Question 100:

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

    #include

    #include

    int main ()

    {

    std::vectorv1;

    for(int i = 0; i<10; i++) {v1.push_back(i); }

    std::vector v2(v1.begin()+2, v1.end()?2);

    std::vector::iterator it = v2.begin();

    for( ; it != v2.end(); it++) {std::cout<<*it++<<" "; }std::cout<

    return 0;

    }

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

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.