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

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

    #include

    #include

    #include

    using namespace std;

    int main(){

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

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

    map m;

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

    m.insert(pair(second[i],first[i]));

    }

    if (m[11] == "eleven") {

    cout<<"eleven ";

    }

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

    cout<second<<" ";

    }

    cout<

    return 0;

    }

    A. program outputs: one two three four five six seven eight nine ten 11
    B. program outputs: one two three four five six seven eight nine ten 10
    C. program outputs: one two three four five six seven eight nine ten 10
    D. program outputs: eleven one two three four five six seven eight nine ten 10
    E. runtime exception

  • Question 22:

    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,1,2,3,4,5};

    vector v (t,t+10);

    vector::iterator it;

    int m1[] = {1, 2, 3};

    it = search (v.begin(), v.end(), m1, m1+3);

    cout << "found at position: " << it?v.begin() << endl;

    return 0;

    }

    Program outputs:

    A. found at position: 5
    B. found at position: 0
    C. found at position: 6
    D. found at position: 1
    E. found at position: 10

  • Question 23:

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

    #include

    using namespace std;

    class C {};

    template

    class A {

    T_v;

    public:

    A() {}

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

    T getV() { return _v; }

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

    };

    int main()

    {

    A b;

    Aa;

    a.add(C());

    cout << b.getV() <

    return 0;

    }

    A. program will display:0
    B. program will not compile
    C. program will compile
    D. program will cause runtime exception

  • Question 24:

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

    map m;

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

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

    }

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

    m.erase(3);

    }

    for (map::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 3 3 4 4 5 5
    E. program outputs: one two three four five

  • Question 25:

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

    v1.resize(4);

    std::vector::iterator it = v1.end();

    v1.insert(v1.end()?1, 4);

    for(int i=0 ; i<= v1.size(); i++) {std::cout<

    return 0;

    }

    A. compilation error
    B. program outputs 0 1 2 3 4
    C. program outputs 0 2 4 8 6 and exception
    D. program outputs 0 2 4 6 8
    E. program outputs 0 2 4 8 6

  • Question 26:

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

    #include

    #include

    #include

    using namespace std;

    int main ()

    {

    string s;

    getline(cin, s);

    stringstream input(s);

    stringstream output;

    for( ; !input.fail() ; )

    {

    int i;

    input>>i;

    output<

    }

    cout<

    return 0;

    }

    Program will output:

    A. 1 2 3
    B. 1 2 3 3
    C. 0x1 0x2 0x3
    D. 0x1 0x2 0x3 0x3
    E. program runs forever without output

  • Question 27:

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

    #include

    #include

    #include

    #include

    using namespace std;

    int main()

    {

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

    deque mydeck(t, t+10);list mylist(t,t+10);

    queue first;

    queue second(mydeck);

    queue third(second);

    queue > fourth(mylist);

    mylist.clear();third.clear();

    cout<

    cout<

    return 0;

    }

    A. program outputs: 10 0 10 0
    B. program outputs: 0 0 0 0
    C. program outputs: 10 10 10 10
    D. program outputs: 10 0 0 10
    E. compilation error

  • Question 28:

    What will happen 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) { _v+=a; }

    };

    int main()

    {

    Aa("Hello");

    string s(" world!");

    a.add(s);

    cout << a.getV() <

    return 0;

    }

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

  • Question 29:

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

    deque d1(t, t+10);

    vector v1(d1.rbegin(), d1.rend());

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

    swap_ranges(v1.begin(), v1.end(), d1.begin());

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

    for_each(d1.begin(), d1.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. 1 2 3 4 5 6 7 8 9 10 1 3 8 7 4 2 6 9 5 10
    E. 1 3 8 7 4 2 6 9 5 10 1 2 3 4 5 6 7 8 9 10

  • Question 30:

    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,3,5,1,2,4,4,5};

    vector v (t,t+10);

    vector::iterator it = v.begin();

    while ( (it = adjacent_find (it, v.end())) != v.end()) {

    cout<

    }

    cout<< endl;

    return 0;

    }

    A. program outputs: 2 3
    B. program outputs: 2 7
    C. program outputs: 3 8
    D. compilation error
    E. program will run forever

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.