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

    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;

    }

    struct sequence {

    int val,inc;

    sequence(int s, int i):val(s),inc(i){}

    int operator()(){

    int r = val; val += inc;

    return r;

    }

    };

    int main() {

    vector v1(10);

    fill(v1.begin(), v1.end(), sequence(1,1));

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

    return 0;

    }

    Program outputs:

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

  • Question 102:

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

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

    multiset > s2(v.begin(), v.end());

    for(multiset >::iterator i=s2.begin();i!= s2.end(); i++) {

    cout<<*i<<" ";

    }

    for(multiset::iterator i=s1.begin();i!= s1.end(); i++) {

    cout<<*i<<" ";

    }

    cout<

    return 0;

    }

    The output will be:

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

  • Question 103:

    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<

    struct Add {

    int operator()(int a, int 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(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 104:

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

    #include

    using namespace std;

    int main()

    {

    cout<<100<<" ";

    cout.setf(ios::hex);

    cout<<100<<" ";

    return 0;

    } Program outputs:

    A. 100 64
    B. 100 0x64
    C. 0x64 0x64
    D. 64 0x64
    E. 100 100

  • Question 105:

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

    #include

    using namespace std;

    void g(int a)

    {

    cout<

    }

    template

    void g(A a)

    {

    cout<

    }

    int main()

    {

    int a = 1;

    g(a);

    return 0;

    }

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

  • Question 106:

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

    cout<<*max_element(v1.begin(), v1.end());

    return 0;

    }

    Program outputs:

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

  • Question 107:

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

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

    return 0;

    }

    Program outputs:

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

  • Question 108:

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

    #include

    using namespace std;

    class C {

    public:

    int _c;

    C():_c(0){}

    C(int c) { _c = c;}

    C operator+=(C and b) {

    C tmp;

    tmp._c = _c+b._c;

    return tmp;

    }

    };

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

    {

    A b(2);

    Aa (5);

    Cc;

    a.add(c);

    cout << a.getV() <

    return 0;

    }

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

  • Question 109:

    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.getline(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 110:

    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 10*(1+(start++ %3)); } };

    int main() {

    vector v1(10);

    vector v2(10);

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

    sort(v1.rbegin(), v1.rend());

    unique_copy(v1.begin(),v1.end(), v2.begin());

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

    return 0;

    }

    Program outputs:

    A. 20 30 10 20 30 10 20 30 10 20
    B. 30 20 10 0 0 0 0 0 0 0
    C. 30 0 0 0 0 0 0 0 20 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.