What happens when you attempt to compile and run the following code?
#include
#include
#include
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 template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { B t1[]={3,2,4,1,5}; B t2[]={5,6,8,2,1}; vector v1(10,0); sort(t1, t1+5); sort(t2, t2+5); set_difference(t1,t1+5,t2,t2+5,v1.begin()); for_each(v1.begin(), v1.end(), Out(cout));cout< return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) {
out< } }; struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return start++; } }; int main() { vector vector generate(v1.begin(), v1.end(), Sequence(1)); random(v1.begin(),v1.end()); for_each(v1.begin(), v1.end(), Out return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v=0):val(v){}
int getV() const {return val;}
operator int () const { return val;} };
ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { B t[]={3,2,4,1,5,6,10,8,7,9}; vector v1(t, t+10); transform(v1.begin(), v1.end(), v1.begin(), bind2nd(plus(), 1)); for_each(v1.rbegin(), v1.rend(), Out(cout));cout< return 0; } Program outputs:
What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: 1.1 2.2 3.3
#include
#include
using namespace std;
int main ()
{
int a,b,c;
cin>>a>>b>>c;
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< struct Add { int operator()(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(Add(),1)); for_each(v2.rbegin(), v2.rend(), Out return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main(){
int myints[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };
vector
set
set
for(set
cout<<*i<<" ";
}
for(set
cout<<*i<<" ";
}
cout< return 0; }
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< struct Add : public binary_function int operator() (const int & a, const int & b) const { return a+b; } }; int main() { int t[]={1,2,3,4,5,6,7,8,9,10}; deque deque transform(d1.begin(), d1.end(), d2.begin(), bind2nd(Add(), 1)); for_each(d2.rbegin(), d2.rend(), Out return 0; } Program outputs:
Which lines of the code below contain proper instantiation of queue objects?
#include
#include
#include
#include
#include
using namespace std;
int main()
{
deque
list
vector
queue
queue
queue
queue
queue
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) {
out< struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return start++; } }; int main() { vector vector generate(v1.begin(), v1.end(), Sequence(1)); reverse_copy(v1.begin(),v1.end(), v2.rbegin()); sort(v2.begin(), v2.end(), less_equal for_each(v2.begin(), v2.end(), Out return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
class B { int val;
public:
B(int v):val(v){} B(){}
int getV() const {return val;} };
ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; deque d1(t, t+10); deque::iterator it = lower_bound(d1.begin(), d1.end(), 4); for_each(it, d1.end(), Out(cout));cout< return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
template
void print(T start, T end) {
while (start != end) {
std::cout << *start << " "; start++;
}
}
int main()
{
int t1[] ={ 1, 7, 8, 4, 5 };
list
int t2[] ={ 3, 2, 6, 9, 0 };
list
l1.sort();
list
it++; it++;
l1.splice(l1.end(),l2, it, l2.end());
print(l1.begin(), l1.end()); cout<<"Size:"< print(l2.begin(), l2.end()); cout<<"Size:"< return 0; }
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];
}
map
cout<
return 0;
}
Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
int main ()
{
std::vector
for(int i = 10; i>0; i??)
{
v1.push_back(i);
}
std::vector
int sum = 0;
while(it != v1.end())
{
sum+=it++;
}
std::cout<<*v1.erase(v1.begin(),v1.end()?3)<<" "< return 0; }
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< int main() { int t1[]={3,2,4,1,5}; int t2[]={6,10,8,7,9}; vector sort(t1, t1+5); sort(t2, t2+5); copy(t1,t1+5,v1.begin()); copy(t2,t2+5,v1.begin()+5); merge(v1.begin(), v1.begin()+5,v1.end()); for_each(v1.begin(), v1.end(), Out return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
int main ()
{
std::vector
for(int i = 0; i<10; i++) {v1.push_back(i); }
v1.resize(4);
std::vector
v1.insert(v1.end()?1, 4);
for(int i=0 ; i<= v1.size(); i++) {std::cout< return 0; }
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main ()
{
int t[] = {1, 2 ,3 ,4 ,5};
vector
deque
d1.assign(v1.end(), v1.begin());
for(int i=0; i { cout< } cout< return 0; }
What happens when you attempt to compile and run the following code?
#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
copy(t, t+10, v1.end());
for_each(v1.begin(), v1.end(), myfunction);
return 0;
}
Program outputs:
What happens when you attempt to compile and run the following code? Choose all possible answers.
#include
using namespace std;
class C {
public:
int _c;
C():_c(0){}
C(int c) { _c = c;}
C operator+=(C & b) {
C tmp; tmp._c = _c+b._c;
return tmp;
} };
ostream & operator<<(ostream & c, const C & v) {
c< template class A { T_v; public: A() {} A(T v): _v(v){} T getV() { return _v; } void add(T & a) { _v+=a; } }; int main() { A A a.add(C()); cout << a.getV() < return 0; }
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main () {
int t[] = {1,2,3,4,5,1,2,3,4,5};
vector
vector
int m1[] = {1, 2, 3};
it = search (v.begin(), v.end(), m1, m1+3);
cout << "found at position: " << it?v.begin() << endl;
return 0;
}
Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
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 ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; set s1(t, t+10); sort(s1.begin(), s1.end()); for_each(s1.begin(), s1.end(), Out(cout));cout< return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< struct Add { int operator()(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(), bind1st(ptr_fun (Add()), 1)); for_each(v2.rbegin(), v2.rend(), Out return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< bool Greater(int v1, int v2) { return v1 int main() { int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; vector sort(v1.begin(), v1.end(), Greater); for_each(v1.begin(), v1.end(), Out return 0; } Program outputs:
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:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< struct Sequence { int start; Sequence(int start):start(start){} int operator()() {return 10*(1+(start++ %3));} }; int main() { deque generate(d1.begin(), d1.end(), Sequence(1)); sort(d1.begin(), d1.end()); pair for_each(result.first, result.second, Out return 0; } Program outputs:
What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: one two three
#include
#include
using namespace std;
int main ()
{
string a;
cin>>a;
What happens when you attempt to compile and run the following code?
#include
#include
#include
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 ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< int main() { int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20}; deque d1(t, t+10); sort(d1.begin(), d1.end()); pair for_each(result.first, result.second, Out(cout));cout< return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< struct Add : public binary_function int operator() (const int & a, const int & b) const { 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(), bind1st(Add(), 1)); for_each(v2.rbegin(), v2.rend(), Out return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
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 }; ostream & operator <<(ostream & out, const B & v) { out< template ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out< }; int main() { B t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; B t1[]={B(1),B(2),B(3),B(4)}; deque d1(t, t+10); set s1(t, t+10); sort(d1.begin(), d1.end()); cout< < return 0; } Program outputs:
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main ()
{
int t[] = {1, 2 ,3 ,4 ,5};
vector
list
l1.assign(v1.end(), v1.begin());
for(int i=0; i { cout< } cout< return 0; }
What happens when you attempt to compile and run the following code?
#include
#include
#include
#include
using namespace std;
template
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out< int main() { int t[]={3,2,4,1,5,6,10,8,7,9}; vector for_each(v1.begin(), v1.end(), bind2nd(plus for_each(v1.rbegin(), v1.rend(), Out return 0; } Program outputs:
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;
}
C++ Certified Professional Programmer | CPP Questions Answers | CPP Test Prep | C++ Certified Professional Programmer Questions PDF | CPP Online Exam | CPP Practice Test | CPP PDF | CPP Test Questions | CPP Study Material | CPP Exam Preparation | CPP Valid Dumps | CPP Real Questions | C++ Certified Professional Programmer CPP Exam Questions