CPP-22-02 Practice Online

Quickly grab our CPP-22-02 product now and kickstart your exam preparation today!

Name: CPP - C++ Certified Professional Programmer
Exam Code: CPP-22-02
Certification: C++ Certified Professional Programmer
Vendor: C++ Institute
Total Questions: 230
Last Updated: May 06, 2024
Page:    1 / 46      
Total 230 Questions | Updated On: May 06, 2024
Demo Download
Question 1

What will happen when you attempt to compile and run the code below, assuming that you
 enter the following sequence: 1 2 3 end<enter>?
 #include <iostream>
 #include <string>
 #include <list>
 #include <algorithm>
 using namespace std;
 template<class T>struct Out {
 ostream & out;
 Out(ostream & o): out(o){}
 void operator() (const T & val ) {out<<val<<" "; } };
 int main ()
 {
 list<int> l;
 for( ; !cin.bad() ; )
 {
 int i;
 cin>>i;
 l.push_back(i);
 }
 for_each(l.begin(), l.end(), Out<int>(cout));
 return 0;
}
Program will output:


Answer: A

Question 2

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 3

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

Question 4

What will be output of the program when you attempt to compile and run the following
code?
 #include <iostream>
 #include <map>
 #include <vector>
 #include <string>
 using namespace std;
 int main(){
 int second[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };
 string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","zero"};
 multimap<int,string> m;for(int i=0; i<10; i++) {
 m.insert(pair<int,string>(second[i],first[i]));
 }
 m[0]="ten";
 m.insert(pair<int,string>(1,"eleven"));
 for(multimap<int, string>::iterator i=m.begin();i!= m.end(); i++) {
 cout<<i?>second<<" ";
 }
 return 0;
 }


Answer: A

Question 5

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

Page:    1 / 46      
Total 230 Questions | Updated On: May 06, 2024
Demo Download