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

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

    #include

    using namespace std;

    template

    class A {

    T_v;

    public:

    A() {}

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

    T getV() { return _v; }

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

    template

    U get(U a) {

    return (U)(_v);

    }

    };

    int main()

    {

    A a(1);

    a.add(10);

    cout.setf( ios::showpoint);

    cout << a.getV() << " " << a.get(1.0)<

    return 0;

    }

    A. program will display: 11 11
    B. program will not compile
    C. program will display: 11.0000 11
    D. program will display: 11 11.000

  • Question 182:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    int main() {

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

    vector v(t, t + 10);

    map m;

    for (vector::iterator i = v.begin(); i != v.end(); i++) {

    stringstream s;s << *i << *i;

    m.insert(pair(*i, s.str()));

    }

    pair::iterator, map::iterator> range;

    range = m.equal_range(6);

    for (map::iterator i = range.first; i != range.second; i++) {

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

    }

    return 0;

    }

    A. program outputs: 6
    B. program outputs: 5 7
    C. program outputs: 6 7
    D. program outputs: 1 5
    E. program outputs: 6 5

  • Question 183:

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

    #include

    using namespace std;

    int main ()

    {

    float f1 = 10.0;

    float f2 = 10.123;

    cout<

    return 0;

    }

    Program outputs:

    A. 10 10
    B. 10.0 10.123
    C. compilation error
    D. 10 10.123

  • Question 184:

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

    generate(v1.rbegin(), v1.rend(), Sequence(1));

    rotate(v1.begin(),v1.begin() + 1, 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. 9 8 7 6 5 4 3 2 1 10
    D. 1 10 9 8 7 6 5 4 3 2

  • Question 185:

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

    #include

    #include

    using namespace std;

    int main ()

    {

    float f = 10.126;

    cout.unsetf(ios::floatfield);

    cout<

    return 0;

    }

    What will be a mantissa part of the numbers displayed:

    A. 1.0126 1.013
    B. 1.012600 10.013
    C. 10.01260 10.013
    D. 1.012600 1.013
    E. 1.0126 1.01

  • Question 186:

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

    reverse_copy(v1.begin(),v1.end(), v2.rbegin());

    sort(v2.begin(), v2.end(), less_equal());

    for_each(v2.begin(), v2.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. no output
    D. compilation error

  • Question 187:

    Which method added to class B at the marked spot will allow the code below to compile? Choose all possible solutions.

    #include

    #include

    #include

    using namespace std;

    class B { int val;

    public:

    B(int v):val(v){}

    int getV() const {return val;}

    /* Insert Code Here */

    };

    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[]={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;

    }

    A. bool operator < (const B and v) const { return val
    B. bool operator > (const B and v) const { return val
    C. bool operator > (const B and v) const { return val>v.val;}
    D. bool operator == (const B and v) const { return val==v.val;}
    E. operator int () const { return val; }

  • Question 188:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    void myfunction(int i) {

    cout << " " << i;

    }

    int add (int a, int b) { return a+b; }

    int main() {

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

    vector v1(t, t+10);

    set s1(t, t+10);

    deque d1;

    d1.resize(s1.size());

    transform(s1.begin(), s1.end(), v1.begin(), d1.begin(), add);

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

    return 0;

    }

    Program outputs:

    A. 0 0 0 0 0 0 0 0 0 0
    B. 11 7 12 10 7 10 14 16 12 11
    C. compilation error
    D. runtime exception
    E. 20 10 18 12 4 8 14 16 6 2

  • Question 189:

    What will happen when you attempt to compile and run the code below, assuming that file test.in contains the following sequence: 1 2 3?

    #include

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

    ifstream f("test.in");

    list l;

    for( ; f.good() ; ) {

    int i;

    f>>i;

    l.push_back(i);

    }

    f.close();

    for_each(l.begin(), l.end(), Out(cout));

    return 0;

    }

    Program will output:

    A. 1 2 3
    B. 1 2 3 3
    C. no output
    D. compilation error
    E. program runs forever without output

  • Question 190:

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

    #include

    using namespace std;

    template

    void f(A a)

    {

    cout<<1<

    }

    void f(int a)

    {

    cout<<2<

    }

    int main()

    {

    int a = 1;

    f(a);

    return 0;

    }

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

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.