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

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

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

    D. compilation error

  • Question 12:

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

    #include

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

    int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20};

    deque d1(t, t+10);

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

    pair ::iterator, deque::iterator > result = equal_range(d1.begin(), d1.end(), B(20), greater());

    for_each(result.first, result.second, Out(cout));cout<

    return 0;

    }

    Program outputs:

    A. 30 30 30 20 20 20 20 10 10 10

    B. 20 20 20 20

    C. 30 20 20 20 10

    D. 20 20 20 20 10

    E. 30 20 20 20 20 10

  • Question 13:

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

    #include

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

    deque d1(t, t+10);

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

    set s1(t,t+10);

    cout<

    return 0;

    }

    Program outputs:

    A. 1 0

    B. 1 1

    C. 0 0

    D. 0 1

    E. compilation error

  • Question 14:

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

    #include

    #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 t[]={3,2,4,1,5,10,9,7,8,6};

    vector v1(t,t+10);

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

    cout<

    return 0;

    }

    Program outputs:

    A. 3

    B. 1

    C. 6

    D. 10

    E. compilation error

  • Question 15:

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

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

    #include

    #include

    using namespace std;

    int main ()

    {

    bool a,b;

    cin>>a>>b;

    cout<

    return 0;

    }

    Program will output:

    A. truetrue

    B. falsefalse

    C. 11

    D. 00

    E. none of these

  • Question 17:

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

    #include

    #include

    #include

    #include

    using namespace std;

    class B { int val;

    public:

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

    int getV() const {return val;}

    B operator +(const B andb )const { return B(val + b.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<

    template struct Add : public binary_function {

    A operator() (const A and a, const A and b) const { 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 18:

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

    #include

    #include

    using namespace std;

    bool mycomparison (int first, int second){return first>second;}

    template

    void print(T start, T end) {

    while (start != end) {

    std::cout << *start << " "; start++;

    }

    }

    int main()

    {

    int t1[] ={ 1, 7, 8, 4, 5 };

    list l1(t1, t1 + 5);

    int t2[] ={ 3, 2, 6, 9, 0 };

    list l2(t2, t2 + 5);

    l1.sort(mycomparison);

    l2.sort(mycomparison);

    l1.merge(l2,mycomparison);

    print(l1.begin(), l1.end());

    print(l2.begin(), l2.end()); cout<

    return 0;

    }

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

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

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

    D. program outputs: 0 1 2 3 4 5 6 7 8 9 0 2 3 6 9

    E. program outputs: 0 1 2 3 4 5 6 7 8 9

  • Question 19:

    What happens when you attempt to compile and run the following code? Choose all that apply.

    #include

    #include

    using namespace std;

    int main ()

    {

    vectorv1(10, 3);

    v1.push_back(3);

    cout<

    return 0;

    }

    A. program displays 4 4

    B. program displays 10 3

    C. size of vector v1 is 11

    D. all elements of vector v1 are of the same value

  • Question 20:

    What happens when you attempt to compile and run the following code? Choose all possible answers.

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

    } };

    ostream and operator<<(ostream and c, const C and v) {

    c<

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

    a.add(C());

    cout << a.getV() <

    return 0;

    }

    A. program will display:5

    B. program will not compile

    C. program will compile

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