Exam Details

  • Exam Code
    :CPP
  • Exam Name
    :C++ Certified Professional Programmer
  • Certification
    :C++ Institute Certifications
  • Vendor
    :C++ Institute
  • Total Questions
    :228 Q&As
  • Last Updated
    :Jul 17, 2025

C++ Institute C++ Institute Certifications CPP Questions & Answers

  • Question 221:

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

    vectorv1(t, t+5);

    listl1;

    l1.assign(v1.end(), v1.begin());

    for(int i=0; i

    {

    cout<

    }

    cout<

    return 0;

    }

    A. program displays 5 4 3 2 1

    B. program displays 1 2 3 4 5

    C. compilation error

    D. segmentation fault runtime exception

  • Question 222:

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

    B t1[]={3,2,4,1,5};

    B t2[]={6,10,8,7,9};

    vector v1(10);

    sort(t1, t1+5);

    sort(t2, t2+5);

    merge(t1,t1+5,t2,t2+5,v1.begin());

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

    return 0;

    }

    Program outputs:

    A. 1 2 3 4 5 6 10 8 7 9

    B. 3 2 4 1 5 6 7 8 9 10

    C. 3 2 4 1 5 6 10 8 7 9

    D. 1 2 3 4 5 6 7 8 9 10

    E. compilation error

  • Question 223:

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

    B t1[]={3,2,4,1,5};

    B t2[]={5,6,8,2,1};

    vector v1(10,0);

    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. 5 2 1 0 0 0 0 0 0 0

    E. 1 2 5 0 0 0 0 0 0 0

  • Question 224:

    What will happen 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, 0, 3, 4, 1, 2, 0 };

    vector v(t, t + 10);

    multimap m;

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

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

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

    }

    pair::iterator, multimap::iterator> range;

    range = m.equal_range(2);

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

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

    }

    return 0;

    }

    A. 2 2

    B. 1 2

    C. 1 3

    D. 2

    E. 0 2

  • Question 225:

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

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

    #include

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    class B { int val;

    public:

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

    int getV() const {return val;}

    operator int() const { return val; };};

    templatestruct Out {

    ostream and out;

    Out(ostream and o): out(o){}

    void operator() (const T and val ) {out<

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

    fstream f("test.out", ios::trunc|ios::out);

    list l(t, t+10);

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

    f.close();

    f.open("test.out");

    for( ; f.good() ; ) {

    B i;

    f>>i;

    cout<

    }

    f.close();

    return 0;

    }

    A. file test.out will be opened writing

    B. file test.out will be truncated

    C. file test.out will be opened for reading

    D. compilation error

    E. program will display sequence 1 2 3 4 5 6 7 8 9 10

  • Question 227:

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

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

    vectorv(t, t+10);

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

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

    pair::iterator,multiset::iterator> range;

    range = s1.equal_range(6);

    while (range.first != range.second) {

    cout<<*range.first<<" "; range.first++;

    }

    return 0;

    }

    A. program outputs: 6 6

    B. program outputs: 5 7

    C. program outputs: 5 5 6 6 7 7

    D. program outputs: 5 5 7 7

    E. program outputs: 1 1 6 6 5 5

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 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.