Free CPP-22-02 Exam Questions - Easiest Way for Success

Prepare for the C++ Institute CPP-22-02 exam questions with our authentic preparation materials, including free CPP-22-02 practice exam questions and answers. TheExamsLab provides all the support you need to succeed in the CPP - C++ Certified Professional Programmer CPP-22-02 exam. This dedication to student success is why we have the most satisfied CPP-22-02 certification exam candidates worldwide.

Page:    1 / 46      
Total 230 Questions | Updated On: Sep 11, 2024
Add To Cart
Question 1

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;
 }
 struct sequence {
 int val,inc;
 sequence(int s, int i):val(s),inc(i){}
 int operator()(){
 int r = val; val += inc;
 return r;
 }
 };
 int main() {
 vector<int> v1(10);fill(v1.begin(), v1.end(), sequence(1,1));
 for_each(v1.begin(), v1.end(), myfunction);
 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;
 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 3

What happens when you attempt to compile and run the following code?
 #include <deque>
 #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<<" "; } };
 int main() {
 int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};
 deque<int> d1(t, t+10);
 sort(d1.begin(), d1.end());
 deque<int>::iterator it = upper_bound(d1.begin(), d1.end(), 4);
 for_each(it, d1.end(), Out<int>(cout));cout<<endl;
 return 0;
}
Program outputs:


Answer: A
Question 4

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;
 }
 struct sequence {
 int val,inc;
 sequence(int s, int i):val(s),inc(i){}
 int operator()(){
 int r = val; val += inc;
 return r;
 }
 };
 int main() {
 vector<int> v1(10);fill(v1.begin(), v1.end(), sequence(1,1));
 for_each(v1.begin(), v1.end(), myfunction);
 return 0;
 }
Program outputs:


Answer: D
Question 5

What happens when you attempt to compile and run the following code?
 #include <iostream>
 #include <map>
 #include <string>
 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<int,string> m;
 for(int i=0; i<10; i++) {
 m.insert(pair<int,string>(second[i],first[i]));
 }
 if (m[11] == "eleven") {
 cout<<"eleven ";
 }
 for(multimap<int, string>::iterator i=m.begin();i!= m.end(); i++) {
 cout<<i?>second<<" ";
 }cout<<m.size();
 return 0;
 }


Answer: A
Page:    1 / 46      
Total 230 Questions | Updated On: Sep 11, 2024
Add To Cart

© Copyrights TheExamsLab 2024. All Rights Reserved

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