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

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

    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 Add(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(), bind2nd(ptr_fun (Add),1));

    vector::iterator it = find_if(v2.begin(), v2.end(),bind2nd(equal_to(),10));

    cout<<*it<

    return 0;

    }

    Program outputs:

    A. false

    B. true

    C. 10

    D. 0

    E. compilation error

  • Question 213:

    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_ranges(s1.begin(), s1.end(), v1.begin());

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

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

  • Question 214:

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

    #include

    #include

    #include

    using namespace std;

    int main(){

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

    listv(t, t+10);

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

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

    s1.erase(3);

    }

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

    cout<<*i<<" ";

    }

    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. compilation error

  • Question 215:

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

    #include

    #include

    #include

    using namespace std;

    int main() {

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

    map m;

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

    m[i]=t[i];

    }

    pair p(5,5);

    map::iterator it = find(m.begin(), m.end(), p);

    if (it != m.end())

    {

    cout<first<

    }

    else

    {

    cout<<"Not found!\n";

    }

    return 0;

    }

    Program outputs:

    A. 5

    B. Not found!

    C. 10

    D. compilation error

  • Question 216:

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

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

    vector v1(t, t + 10);

    deque d1(t, t + 10);

    set s1(t, t + 10);

    for_each(v1.begin(), v1.end(), myfunction); // Line I

    for_each(d1.begin(), d1.end(), myfunction); // Line II

    for_each(s1.begin(), s1.end(), myfunction); // Line III return 0;

    }

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

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

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

    D. compilation error in line I

    E. compilation error in line III

  • Question 217:

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

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

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

    #include

    #include

    #include

    using namespace std;

    void myfunction(int i) {

    cout << " " << i;

    }

    void multiply (int a) {

    a*2;

    }

    int main() {

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

    vector v1(t, t+10);

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

    iter_swap(v1.begin(),t+9);

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

    return 0;

    }

    Program outputs:

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

    B. compilation error

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

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

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

  • Question 220:

    Which sentence is correct about the code below?

    #include

    #include

    #include

    using namespace std;

    class A {

    int a;

    public:

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

    int getA() const { return a; }

    void setA(int a) { this?>a = a; }

    /* Insert Code Here */

    };

    struct add10 { void operator()(A and a) { a.setA(a.getA() + 10); } };

    int main() {

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

    vector v1(t, t + 10);

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

    vector::iterator it = find(v1.begin(), v1.end(), A(7));

    cout << it?>getA() << endl;

    return 0;

    }

    A. it will compile and print 7

    B. it will not compile

    C. it will compile but the program result is unpredictable

    D. adding code: bool operator !=(const A and b) const { if (this?>a != b.a) { return true; } return false; } at Place 1 will allow the program to compile

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.