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

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

    #include

    #include

    #include

    using namespace std;

    template void print(T start, T end) {

    while (start != end) {

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

    }

    }

    int main(){

    vectorv;

    set s;

    for(int i=10; i>0; i??) {

    v.push_back(i);

    s.push_back(i);

    }

    print(v.begin(), v.end()); print(s.begin(), s.end());cout<

    return 0;

    }

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

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

    C. 10 9 8 7 6 5 4 3 2 1 and unpredictable sequence of number range 1 to 10

    D. compilation error

  • Question 32:

    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, 6 , 7, 8 , 9, 10};

    vectorv1(t, t+10);

    dequed1(t, t+10);

    vector::iterator it1 = v1.begin();

    deque::iterator it2 = d1.begin();

    d1.erase(it2+5);

    it2 = d1.begin();

    cout<<*(it2+5)<<" ";

    v1.erase(it1+5);

    it1 = v1.begin();

    cout<<*(it1+5)<

    }

    A. program outputs: 7 7

    B. program outputs: 6 6

    C. compilation error

    D. result is unpredictable

  • Question 33:

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

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

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

    deque d1(t, t+10);

    set s1(t, t+10);

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

    cout<

    <

    return 0;

    }

    Program outputs:

    A. 1 1

    B. 1 0

    C. 0 1

    D. 0 0

  • Question 34:

    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(s1, v1);

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

  • Question 35:

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

    vector v1(10,1);

    fill(v1.begin()+2, v1.end()?2,2);

    fill_n(v1.begin()+4,2,3);

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

    return 0;

    }

    Program outputs:

    A. 1 1 2 2 3 3 2 2 1 1

    B. 1 1 2 2 2 2 2 2 1 1

    C. compilation error

    D. none of these

  • Question 36:

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

    #include

    #include

    using namespace std;

    int main() {

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

    string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"};

    multimap m;

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

    m.insert(pair(t[i], s[i]));

    }

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

    m.erase(3);

    }

    for (multimap::iterator i = m.begin(); i != m.end(); i++) {

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

    }

    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 2 4 4 5 5

    E. program outputs: one two three four five

  • Question 37:

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

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    templateclass B { T val;

    public:

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

    T getV() const {return val;} };

    templateostream 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<

    string tolower(const string and s) {

    string tmp(s);

    for(unsigned i = 0; i< tmp.size(); ++i){

    tmp[i] = tolower(tmp[i]); }

    return tmp; }

    bool Less(const B anda, const B andb) { return tolower(a.getV())

    int main() {

    string t[]={"aaa","bbb","Aaa", "Bbb","aAa","bBb","aaA","bbB"};

    vector > v1; v1.assign(t, t+8);

    stable_sort(v1.begin(), v1.end(), Less);

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

    return 0;

    }

    Program outputs:

    A. Aaa aaa aAa aaA bbb Bbb bBb bbB

    B. Aaa aaa aAa aaA bbb Bbb bbB bBb

    C. aaa Aaa aAa aaA bbb Bbb bBb bbB

    D. the exact output is impossible to determine

  • Question 38:

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

    #include

    #include

    #include

    using namespace std;

    int main(){

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

    string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight"," ten"};

    multimap m;

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

    m.insert(pair(second[i],first[i]));

    }

    if (m[11] == "eleven") {

    cout<<"eleven ";

    }

    for(multimap::iterator i=m.begin();i!= m.end(); i++) {

    cout<second<<" ";

    }

    cout<

    return 0;

    }

    A. program outputs: one two three four five six seven eight nine ten 11

    B. program outputs: one two three four five six seven eight nine ten 10

    C. program outputs: one two three four five six seven eight nine ten 10

    D. program outputs: eleven one two three four five six seven eight nine ten 10

    E. compilation error

  • Question 39:

    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 Add {

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

    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, 6 , 7, 8 , 9, 10};

    vectorv1(t, t+10);

    dequed1(t, t+10);

    d1.empty();

    v1.empty();

    if (v1.isempty())

    {

    cout<<"I am empty ";

    }

    else

    {

    cout<<"I am not empty ";

    }

    cout<

    return 0;

    }

    A. program outputs: I am empty 0 0

    B. program outputs: I am not empty 0 0

    C. compilation error

    D. program outputs: I am not empty 10 10

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.