
Get C++ Institute CPP Dumps Questions [2021] To Gain Brilliant Result
CPP dumps - DumpsTorrent - 100% Passing Guarantee
NEW QUESTION 90
What happens when you attempt to compile and run the following code?
#include <deque>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out<<val<<" "; }
};
bool Compare(char a, char b) { return tolower(a) < tolower(b);}
int main() {
char s[]={"qwerty"};
char t1[]={"ert"};
char t2[]={"ERT"};
sort(s, s+6);
cout<<includes(s,s+6, t1,t1+3, Compare)<<" "<<includes(s,s+6, t2,t2+3, Compare)<<endl; return 0;
}
Program outputs:
- A. 1 1
- B. 0 1
- C. 0 0
- D. 1 0
Answer: A
NEW QUESTION 91
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;
}
int main() {
vector<int> v1(10,1);
fill(v1.begin()+2, v1.end()?2,2);
fill_n(v1.begin()+4,2,3);
for_each(v1.begin(), v1.end(), myfunction);
return 0;
}
Program outputs:
- A. 1 1 2 2 3 3 2 2 1 1
- B. none of these
- C. 1 1 2 2 2 2 2 2 1 1
- D. compilation error
Answer: A
NEW QUESTION 92
What happens when you attempt to compile and run the following code?
include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
using namespace std;
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector<int> v1(t, t + 10);
deque<int> d1(t, t + 10);
set<int> s1(t, t + 10);
cout<<find(v1.begin(), v1.end(), 6)<<" "<<find(d1.begin(), d1.end(), 6)<<"
"<<find(s1.begin(), s1.end(), 6);
return 0;
}
- A. compilation error
- B. program outputs: 6 6 6
- C. none of these
- D. program outputs: 3 3 5
- E. program outputs: 3 6 5
Answer: A
NEW QUESTION 93
What happens when you attempt to compile and run the following code?
# include <vector>
# include <set>
# 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<<" "; } };
template <typename T> struct Sequence {
T start; T step;
Sequence(T start, T step):start(start), step(step){}
T operator()() { T v = start; start+=step; return v; } };
bool Less(float a, float b) { return int(a)<int(b);}
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<float> v1; v1.assign(t, t+10);
stable_sort(v1.begin(), v1.end(), Less);
for_each(v1.begin(), v1.end(), Out<float>(cout));cout<<endl;
return 0;
}
Program outputs:
- A. the exact output is impossible to determine
- B. 1.13 1.32 1.66 1.96 2.28 2.3 2.62 2.98 3.64 3.94
- C. 1.66 1.32 1.96 1.13 2.28 2.3 2.98 2.62 3.94 3.64
- D. compilation error
- E. 3.94 3.64 2.98 2.62 2.3 2.28 1.96 1.66 1.32 1.13
Answer: C
NEW QUESTION 94
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main() {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
vector<int> v1(t, t + 15);
set<int> s1(t, t + 15);
pair<set<int>::iterator, vector<int>::iterator > resultSet = mismatch(s1.begin(), s1.end(), v1.begin());
cout<<*resultSet.first<<" "<<*resultSet.second<<endl;
return 0;
}
Program outputs:
- A. 2 4
- B. 0 5
- C. 4 2
- D. compilation error
Answer: C
NEW QUESTION 95
What happens when you attempt to compile and run the following code?
# include <iostream>
# include <algorithm>
#include <vector>
using namespace std;
int main () {
int t[] = {1,2,3,3,5,1,2,4,4,5};
vector<int> v (t,t+10);
vector<int>::iterator it = v.begin();
while ( (it = adjacent_find (it, v.end())) != v.end()) {
cout<<it?v.begin()<<" ";it++;
}
cout<< endl;
return 0;
}
- A. program will run forever
- B. program outputs: 2 7
- C. program outputs: 3 8
- D. compilation error
- E. program outputs: 2 3
Answer: B
NEW QUESTION 96
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;
}
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
set<int> s1(t, t+10);
vector<int> v1(s1.rbegin(), s1.rend());
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. compilation error
- B. 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1
- 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 1 2 3 4 5 6 7 8 9 10
Answer: A
NEW QUESTION 97
What happens when you attempt to compile and run the following code?
# include <vector>
# 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<<" ";
}
};
struct Sequence {
int start;
Sequence(int start):start(start){}
int operator()() {
return start++ ; }};
int main() {
vector<int> v1(10);
generate(v1.rbegin(), v1.rend(), Sequence(1));
rotate(v1.begin(),v1.begin() + 1, v1.end() );
for_each(v1.begin(), v1.end(), Out<int>(cout) );cout<<endl;
return 0;
}
Program outputs:
- A. 9 8 7 6 5 4 3 2 1 10
- B. 1 2 3 4 5 6 7 8 9 10
- C. 10 9 8 7 6 5 4 3 2 1
- D. 1 10 9 8 7 6 5 4 3 2
Answer: A
NEW QUESTION 98
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:
- A. true false
- B. true 0
- C. 1 false
- D. compilation error
- E. 1 0
Answer: C
NEW QUESTION 99
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;
}
- A. compilation error
- B. program outputs: 0 1 2 3 4 5 6 7 8 9 10
- C. program outputs: 0 1 2 3 4 5 6 7 8 9
- D. program outputs: 10 0 1 2 3 4 5 6 7 8 9
Answer: A
NEW QUESTION 100
Which pieces of code inserted independently into places marked 1 and 2 will cause the program to compile and display: 0 1 2 3 4 5 6 7 8 9? Choose all that apply.
#include <list>
#include <iostream>
using namespace std;
class A { int a; public:
A(int a){ this?>a=a;}
//insert code here 1
};
//insert code here 2
template<class T> void print(T start, T end) {
while (start != end) {
std::cout << *start << " "; start++;
}
}
int main() {
A t1[] ={ 1, 7, 8, 4, 5 };list<A> l1(t1, t1 + 5);
A t2[] ={ 3, 2, 6, 9, 0 };list<A> l2(t2, t2 + 5);
l1.sort();l2.sort();l1.merge(l2);
print(l1.begin(), l1.end());
print(l2.begin(), l2.end()); cout<<endl;
return 0;
}
- A. place 1: operator int() { return a; }
- B. place 1: bool operator < (const A & b) { return this?>a< b.a;}
place 2: ostream & operator <<(ostream & c, const A & a) { c<<a.a; return c;} - C. place 1: operator int() { return a; }
bool operator < (const A & b) { return this?>a< b.a;} - D. place 1: bool operator < (const A & b) { return this?>a< b.a;}
friend ostream & operator <<(ostream & c, const A & a);
place 2: ostream & operator <<(ostream & c, const A & a) { c<<a.a; return c;} - E. place 1: bool operator < (const A & b) { return this?>a< b.a;}
Answer: A,C,D
NEW QUESTION 101
What happens when you attempt to compile and run the following code?
# include <vector>
# 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 t1[]={3,2,4,1,5};
int t2[]={5,6,8,2,1};
vector<int> v1(10);
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<int>(cout));cout<<endl;
return 0;
}
Program outputs:
- A. 1 2 5 0 0 0 0 0 0 0
- B. 1 2 3 4 5 6 8 2 1 0
- C. 1 2 3 4 5 6 8 0 0 0
- D. compilation error
- E. 1 1 2 2 3 4 5 5 6 8
Answer: A
NEW QUESTION 102
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<enter>?
# include <iostream>
# include <string>
using namespace std;
int main ()
{
int a,b,c;
cin>>a>>b>>c;
cout<<a<<b<<c<<endl;
return 0;
}
Program will output:
- A. 0
- B. 1.12.23.3
- C. none of these
- D. 1.1 2.2 3.3
- E. 1 2 3
Answer: C
NEW QUESTION 103
What happens when you attempt to compile and run the following code?
#include <vector>
#include <set>
#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<<" "; } };
struct Sequence {
int start;
Sequence(int start):start(start){}
int operator()() { return start++; } };
int main() {
vector<int> v1(10);
generate_n(v1.begin(), 10, Sequence(1));
random_shuffle(v1.rbegin(), v1.rend());
sort(v1.begin(), v1.end(), great<int>());
for_each(v1.begin(), v1.end(), Out<int>(cout));cout<<endl;
return 0;
}
Program outputs:
- A. compilation error
- B. 8 10 5 1 4 6 2 7 9 3
- C. 1 2 3 4 5 6 7 8 9 10
- D. 10 9 8 7 6 5 4 3 2 1
Answer: A
NEW QUESTION 104
What happens when you attempt to compile and run the following code?
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out<<val<<" "; } };
int main() {
string t[]={"aaa","Aaa", "aAa","aaA","bbb","Bbb", "bBb", "bbB"};
vector<string> v1(t, t+8);
sort(v1.begin(), v1.end());
for_each(v1.begin(), v1.end(), Out<string>(cout));cout<<endl;
return 0;
}
Program outputs:
- A. Aaa Bbb aAa aaA aaa bBb bbB bbb
- B. bBb bbB bbb Aaa aAa Bbb aaA aaa
- C. Aaa aAa Bbb aaA aaa bBb bbB bbb
- D. compilation error
- E. Aaa aAa bBb bbB bbb Bbb aaA aaa
Answer: A
NEW QUESTION 105
What happens when you attempt to compile and run the following code?
#include <vector>
using namespace std;
int main ()
{
std::vector<int>v1;
v1.push_back(10);
return 0;
}
- A. compilation fails due to error in line 5
- B. exception is thrown during run time
- C. compilation fails due to error in line 2
- D. code compiles and executes successfully
Answer: D
NEW QUESTION 106
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
template<int>
void g(int a)
{
cout<<a?1<<endl;
}
template<class A>
void g(A a)
{
cout<<a+1<<endl;
}
int main()
{
int a = 1;
g(a);
return 0;
}
- A. program displays: 2
- B. runtime exception
- C. program displays: 1
- D. compilation error
Answer: A
NEW QUESTION 107
What happens when you attempt to compile and run the following code?
# include <iostream>
# include <string>
using namespace std;
template <class T>
class A {
T_v;
public:
A() {}
A(T v): _v(v){}
T getV() { return _v; }
void add(T & a) { _v+=a; }
void add(string & a) {
_v.insert(0, a);
}
};
int main()
{
A<string>a("Hello");
string s(" world!");
a.add(s);
cout << a.getV() <<endl;
return 0;
}
- A. compilation error
- B. program will run without any output
- C. program will display: world!Hello
- D. program will display: Hello world!
Answer: A
NEW QUESTION 108
What will happen when you attempt to compile and run the code below, assuming you enter the following sequence: 1 2 3<enter>?
#include <iostream>
using namespace std;
int main ()
{
int a,b,c;
cin>>a>>b>>c;
cout<<a<<b<<c<<endl;
return 0;
}
Program will output:
- A. the result is unspecified
- B. compilation error
- C. 0
- D. 1 2 3
- E. 1
Answer: E
NEW QUESTION 109
What will happen when you attempt to compile and run the following code?
#include <iostream>
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;
}
};
template <class T>
class A {
T _v;
public:
A() {}
A(T v): _v(v){}
T getV() { return _v; }
void add(T & a) { _v+=a; }
};
int main()
{
A<int> b(2);
A<C> a (5);
C c;
a.add(c);
cout << a.getV() <<endl;
return 0;
}
- A. program will compile
- B. program will display:2
- C. program will not compile
- D. program will cause runtime exception
Answer: C
NEW QUESTION 110
What happens when you attempt to compile and run the following code?
#include <deque>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
template<typename T>
void print(T start, T end)
{
while (start != end)
cout<<*start++;
}
int main ()
{
string t[] = {"one", "two" ,"three" ,"four", "five"};
vector<string>v1(t, t+5);
deque<string>d1(v1.rbegin(), v1.rend());
d1.push_back("zero");
print(d1[0].rbegin(),d1[0].rend());
return 0;
}
- A. program outputs: five
- B. program outputs: orez
- C. compilation error
- D. program outputs: evif
Answer: D
NEW QUESTION 111
What will happen when you attempt to compile and run the following code?
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
float f = 10.126;
cout.unsetf(ios::floatfield);
cout<<scientific<<f<<" "<<setprecision(3)<<f<<endl;
return 0;
}
What will be a mantissa part of the numbers displayed:
- A. 1.0126 1.013
- B. 1.0126 1.01
- C. 1.012600 1.013
- D. 10.01260 10.013
- E. 1.012600 10.013
Answer: C
NEW QUESTION 112
......
Get 100% Passing Success With True CPP Exam: https://www.dumpstorrent.com/CPP-exam-dumps-torrent.html