×

Special Offer! November Sale at DumpsCity! Get 20% Off on All Certification Exam Questions. Use Code: DC20OFF

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: Nov 11, 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;
       int main ()
       {
       float f1 = 10.0;
       float f2 = 10.123;
       cout<<noshowpoint<<f1<<" "<<f2;
       return 0;
       }
      Program outputs:

      Answer: D
  • Question 2
    • What happens when you attempt to compile and run the following code?
       #include <iostream>
       using namespace std;int main()
       {
       cout<<true<<" "<<boolalpha<<false;
       return 0;
       }
      Program outputs:

      Answer: C
  • Question 3
    • What happens when you attempt to compile and run the following code?
       #include <vector>
       #include <iostream>
       #include <algorithm>
       using namespace std;
       template<typename T>class B { T val;
       public:
       B(T v):val(v){}
       T getV() const {return val;} bool operator < (const B & v) const { return val<v.val;} };
       template<class T>ostream & operator <<(ostream & out, const B<T> & 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<<" "; } };
       bool Less(const B<float> &a, const B<float> &b) { return int(a.getV())<int(b.getV());}
       int main() {
       float t[]={2.28, 1.66, 1.32, 3.94, 3.64, 2.3, 2.98, 1.96, 2.62, 1.13};
       vector<B<float> > v1; v1.assign(t, t+10);
       stable_sort(v1.begin(), v1.end(), Less);
       for_each(v1.begin(), v1.end(), Out<B<float> >(cout));cout<<endl;
       return 0;
       }
      Program outputs:

      Answer: A
  • Question 4
    • What happens when you attempt to compile and run the following code?
       #include <vector>
       #include <iostream>
       #include <algorithm>
       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() {
       B t1[]={3,2,4,1,5};
       int t2[]={5,6,8,2,1};
       vector<B> v1(10,0);
       sort(t1, t1+5);
       sort(t2, t2+5);
       set_union(t1,t1+5,t2,t2+5,v1.begin());
       for_each(v1.begin(), v1.end(), Out<B>(cout));cout<<endl;
       return 0;
       }
      Program outputs:


      Answer: A
  • Question 5
    • What happens when you attempt to compile and run the following code?
       #include <deque>
       #include <vector>
       #include <iostream>
       using namespace std;
       int main ()
       {
       int t[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
       vector<int> v1(t, t + 10);
       deque<int> d1(v1.begin(), v1.end());deque<int> d2;
       d2 = d1;
       d2.insert(d1.rbegin(), 10);
       for(int i = 0; i<d1.size(); i++)
       {
       cout<<d1[i]<<" ";
       }
       return 0;
       }

      Answer: D
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.