81. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void show(const vector<int>& vi)
{
for (size_t i = 0; i < vi.size(); ++i)
cout << vi[i];
cout << endl;
}
int main()
{
vector<int> vi;
vi.push_back(3);
vi.push_back(5);
vi.push_back(5);
sort(vi.begin(), vi.end());
show(vi);
while(next_permutation(vi.begin(), vi.end()))
show(vi);
return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void show(const vector<int>& vi)
{
for (size_t i = 0; i < vi.size(); ++i)
cout << vi[i];
cout << endl;
}
int main()
{
vector<int> vi;
vi.push_back(3);
vi.push_back(5);
vi.push_back(5);
sort(vi.begin(), vi.end());
show(vi);
while(next_permutation(vi.begin(), vi.end()))
show(vi);
return 0;
}
82. In how many different ways any-container can be constructed?
83. What does this template function indicates?
==================
template<class T, class U>
U func(T a, U b)
{
cout<<a<<"\t"<<b;
}
==================
==================
template<class T, class U>
U func(T a, U b)
{
cout<<a<<"\t"<<b;
}
==================
84. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> v = {4,2,10,5,1,8};
sort(v.begin(), v.end());
if (binary_search(v.begin(), v.end(), 4))
cout << "found.\n";
else
cout << "not found.\n";
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> v = {4,2,10,5,1,8};
sort(v.begin(), v.end());
if (binary_search(v.begin(), v.end(), 4))
cout << "found.\n";
else
cout << "not found.\n";
return 0;
}
85. Identify the correct statement about throw(type).
86. Which operator is used as catch-all handler?
87. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s = "a long string";
s.insert(s.size() / 2, " * ");
cout << s << endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s = "a long string";
s.insert(s.size() / 2, " * ");
cout << s << endl;
return 0;
}
88. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
v.assign(3, 8);
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> v;
for (int i = 1; i <= 5; i++)
v.push_back(i);
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
v.assign(3, 8);
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
return 0;
}
89. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
myvector.push_back(78);
myvector.push_back(16);
myvector.front() += myvector.back();
cout << myvector.front() << '\n';
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
myvector.push_back(78);
myvector.push_back(16);
myvector.front() += myvector.back();
cout << myvector.front() << '\n';
return 0;
}
90. What is the default operation of adjacent_difference function in numeric library?
Read More Section(C plus plus miscellaneous)
Each Section contains maximum 100 MCQs question on C plus plus miscellaneous. To get more questions visit other sections.
- C plus plus miscellaneous - Section 2
- C plus plus miscellaneous - Section 3
- C plus plus miscellaneous - Section 4
- C plus plus miscellaneous - Section 5
- C plus plus miscellaneous - Section 6
- C plus plus miscellaneous - Section 7
- C plus plus miscellaneous - Section 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11