Free C++ Institute CPP-22-02 Exam Questions

Try our Free Demo Practice Tests for Comprehensive CPP-22-02 Exam Preparation

  • C++ Institute CPP-22-02 Exam Questions
  • Provided By: C++ Institute
  • Exam: CPP - C++ Certified Professional Programmer
  • Certification: C++ Certified Professional Programmer
  • Total Questions: 230
  • Updated On: Apr 29, 2025
  • Rated: 4.9 |
  • Online Users: 460
Page No. 1 of 46
Add To Cart
  • Question 1
    • What happens when you attempt to compile and run the following code?
       #include <iostream>
       using namespace std;
       template<class A>
       void f(A a)
       {
       cout<<1<<endl;
       }
       void f(int a)
       {
       cout<<2<<endl;
       }
       int main(){
       int a = 1;
       f<float>(a);
       return 0;
       }

      Answer: A
  • Question 2
    • What happens when you attempt to compile and run the following code?
       #include <deque>
       #include <iostream>#include <algorithm>
       #include <functional>
       using namespace std;
       class B { int val;
       public:
       B(int v):val(v){}
       int getV() const {return val;} bool operator > (const B & v) const { return val>v.val;} };
       ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;}
       template<class T>struct Out {
       ostream & out; Out(ostream & o): out(o){}
       void operator() (const T & val ) { out<<val<<" "; } };
       int main() {
       int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20};
       deque<B> d1(t, t+10);
       sort(d1.begin(), d1.end(), greater<B>());
       pair<deque<B> ::iterator, deque<B>::iterator > result = equal_range(d1.begin(), d1.end(),
      B(20), greater<B>());
       for_each(result.first, result.second, Out<B>(cout));cout<<endl;
       return 0;
       }
      Program outputs:

      Answer: B
  • Question 3
    • What happens when you attempt to compile and run the following code?
       #include <vector>
       #include <set>
       #include <iostream>
       #include <algorithm>
       using namespace std;
       template<class T>struct Out {
       ostream & out;
       Out(ostream & o): out(o){}
       void operator() (const T & val ) { out<<val<<" "; } };
       struct Sequence {
       int start;
       Sequence(int start):start(start){}
       int operator()() { return start++; } };
       int main() {
       vector<int> v1(10);
       generate_n(v1.begin(), 10, Sequence(1));
       random_shuffle(v1.rbegin(), v1.rend());
       sort(v1.begin(), v1.end(), great<int>());
       for_each(v1.begin(), v1.end(), Out<int>(cout));cout<<endl;
       return 0;
       }
      Program outputs:

      Answer: C
  • Question 4
    • What happens when you attempt to compile and run the following code?
      #include <iostream>
       #include <map>
       #include <vector>
       #include <sstream>
       #include <string>
       using namespace std;
       int main(){
       int t[] ={ 3, 4, 2, 1, 0, 1, 2, 3, 4, 0 };
       vector<int> v(t, t+10);
       multimap<int,string> m;
       for(vector<int>::iterator i=v.begin(); i!=v.end(); i++) {
       stringstream s; s<<*i<<*i; m.insert(pair<int,string>(*i,s.str()));
       }
       for(multimap<int, string>::iterator i=m.begin();i!= m.end(); i++) {
       cout<<*i<<" ";
       }
       return 0;
       } 

      Answer: A
  • Question 5
    • What happens when you attempt to compile and run the following code?
       #include <iostream>
       #include <set>
       #include <list>
       using namespace std;
       int main(){
       int t[] ={ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
       list<int>v(t, t+10);
       multiset<int> s1(v.begin(),v.end());
       if (s1.count(3) == 2) {
       s1.erase(3);
       }
       for(multiset<int>::iterator i=s1.begin();i!= s1.end(); i++) {
       cout<<*i<<" ";
       }
       return 0;
       } 

      Answer: D
PAGE: 1 - 46
Add To Cart

© Copyrights Dumpscity 2025. All Rights Reserved

We use cookies to ensure your best experience. So we hope you are happy to receive all cookies on the Dumpscity.