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: Sep 25, 2024
  • 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 <iostream>
       #include <algorithm>
       #include <vector>
       #include <set>
       using namespace std;
       void myfunction(int i) {
       cout << " " << i;
       }
       int multiply (int a) {
       return a*2;
       }
       int main() {
       int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
       vector<int> v1(t, t+10);
       set<int> s1(t, t+10);
       transform(s1.begin(), s1.end(), v1.begin(), multiply);
       transform(v1.begin(), v1.end(), s1.begin(), multiply);
       for_each(s1.begin(), s1.end(), myfunction);
       return 0;
       }
      Program outputs:

      Answer: D
  • Question 4
    • What happens when you attempt to compile and run the following code?
       #include <list>
       #include <iostream>
       using namespace std;
       template<class T>
       void print(T start, T end) {
       while (start != end) {
       std::cout << *start << " "; start++;
       }
       }
       int main()
       {
       int t1[] ={ 1, 7, 8, 4, 5 };
       list<int> l1(t1, t1 + 5);
       int t2[] ={ 3, 2, 6, 9, 0 };
       list<int> l2(t2, t2 + 5);
       l1.sort();
       list<int>::iterator it = l2.begin();
       it++; it++;
      l1.splice(l1.end(),l2, it, l2.end());
       print(l1.begin(), l1.end()); cout<<"Size:"<<l1.size()<<" ";
       print(l2.begin(), l2.end()); cout<<"Size:"<<l2.size()<<endl;
       return 0;
       }

      Answer: A
  • Question 5
    • 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
PAGE: 1 - 46
Add To Cart

© Copyrights Dumpscity 2024. All Rights Reserved

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