What happens when you attempt to compile and run the following code? #include
#include
#include
#include
using namespace std;
void myfunction(int i) {
cout << " " << i;
}
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
deque
vector
sort(d1.begin(), d1.end());
swap_ranges(v1.begin(), v1.end(), d1.begin());
for_each(v1.begin(), v1.end(), myfunction);
for_each(d1.begin(), d1.end(), myfunction);
return 0;
}
Program outputs:
A. 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10
B. compilation error
C. 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
D. 1 2 3 4 5 6 7 8 9 10 1 3 8 7 4 2 6 9 5 10
E. 1 3 8 7 4 2 6 9 5 10 1 2 3 4 5 6 7 8 9 10
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator() (const T and val ) { out< int Add(int a, int b) { return a+b; } int main() { int t[]={1,2,3,4,5,6,7,8,9,10}; vector vector transform(v1.begin(), v1.end(), v2.begin(), bind2nd(ptr_fun (Add),1)); vector cout<<*it< return 0; } Program outputs: A. false B. true C. 10 D. 0 E. compilation error
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
void myfunction(int i) {
cout << " " << i;
}
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
set
vector
swap_ranges(s1.begin(), s1.end(), v1.begin());
for_each(v1.begin(), v1.end(), myfunction);
for_each(s1.begin(), s1.end(), myfunction);
return 0;
}
Program outputs:
A. 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10
B. compilation error
C. 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
D. 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1
E. 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main(){
int t[] ={ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };
list
set
if (s1.count(3) == 2) {
s1.erase(3);
}
for(set
cout<<*i<<" ";
}
return 0;
}
A. program outputs: 1 2 3 4 5
B. program outputs: 1 2 4 5
C. program outputs: 1 1 2 2 3 4 4 5 5
D. program outputs: 1 1 2 3 3 4 4 5 5
E. compilation error
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
map
for(int i=0; i < 10; i++) {
m[i]=t[i];
}
pair
map
if (it != m.end())
{
cout< } else { cout<<"Not found!\n"; } return 0; } Program outputs: A. 5 B. Not found! C. 10 D. compilation error
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
#include
using namespace std;
void myfunction(int i) {
cout << " " << i;
}
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector
deque
set
for_each(v1.begin(), v1.end(), myfunction); // Line I
for_each(d1.begin(), d1.end(), myfunction); // Line II
for_each(s1.begin(), s1.end(), myfunction); // Line III return 0;
}
A. program outputs: 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 1 2 3 4 5 6 7 8 9 10
B. program outputs: 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1
C. program outputs: 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
D. compilation error in line I
E. compilation error in line III
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator() (const T and val ) { out< int main() { int t1[]={3,2,4,1,5}; int t2[]={5,6,8,2,1}; vector sort(t1, t1+5); sort(t2, t2+5); set_intersection(t1,t1+5,t2,t2+5,v1.begin()); for_each(v1.begin(), v1.end(), Out return 0; } Program outputs: A. compilation error B. 1 2 3 4 5 6 8 0 0 0 C. 1 2 3 4 5 6 8 2 1 0 D. 1 1 2 2 3 4 5 5 6 8 E. 1 2 5 0 0 0 0 0 0 0
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream and out;
Out(ostream and o): out(o){}
void operator() (const T and val ) { out< int main() { int t[]={3,2,4,1,5,10,9,7,8,6}; vector cout<<*max_element(v1.begin(), v1.end()); return 0; } Program outputs: A. 3 B. 1 C. 6 D. 10 E. compilation error
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
void myfunction(int i) {
cout << " " << i;
}
void multiply (int a) {
a*2;
}
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector
for_each(v1.begin(), v1.end(), multiply);
iter_swap(v1.begin(),t+9);
for_each(v1.begin(), v1.end(), myfunction);
return 0;
}
Program outputs:
A. 1 5 9 6 2 4 7 8 3 1
B. compilation error
C. 1 2 3 4 5 6 7 8 9 10
D. 10 9 8 7 6 5 4 3 2 1
E. 10 5 9 6 2 4 7 8 3 1
Which sentence is correct about the code below?
#include
#include
#include
using namespace std;
class A {
int a;
public:
A(int a) : a(a) {}
int getA() const { return a; }
void setA(int a) { this?>a = a; }
/* Insert Code Here */
};
struct add10 { void operator()(A and a) { a.setA(a.getA() + 10); } };
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector v1(t, t + 10);
for_each(v1.begin(), v1.end(), add10());
vector::iterator it = find(v1.begin(), v1.end(), A(7));
cout << it?>getA() << endl;
return 0;
}
A. it will compile and print 7
B. it will not compile
C. it will compile but the program result is unpredictable
D. adding code: bool operator !=(const A and b) const { if (this?>a != b.a) { return true; } return false; } at Place 1 will allow the program to compile
Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPP exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.