51. Which of the following is correct about Input Iterators?
52. How many types of sequence operations are provided by the C++ algorithm STL?
53. What will be the output of the following C++ code?
#include <iostream>
#include <memory>
#include <string>
using namespace std;
int main ()
{
string numbers[] = {"steve", "jobs"};
pair <string*, ptrdiff_t> result = get_temporary_buffer<string>(2);
if (result.second>0)
{
uninitialized_copy ( numbers, numbers + result.second, result.first );
for (int i = 0; i < result.second; i++)
cout << result.first[i] << " ";
return_temporary_buffer(result.first);
}
return 0;
}
#include <iostream>
#include <memory>
#include <string>
using namespace std;
int main ()
{
string numbers[] = {"steve", "jobs"};
pair <string*, ptrdiff_t> result = get_temporary_buffer<string>(2);
if (result.second>0)
{
uninitialized_copy ( numbers, numbers + result.second, result.first );
for (int i = 0; i < result.second; i++)
cout << result.first[i] << " ";
return_temporary_buffer(result.first);
}
return 0;
}
54. What kind of iteration does forward_list provide in C++?
55. Which of the following header file is needed to use vectors in your program?
56. What will be the output of the following C++ code?
#include <string>
#include <iostream>
using namespace std;
void string_permutation( string& orig, string& perm )
{
if (orig.empty())
{
cout<<perm<<endl;
return;
}
for (int i = 0; i < orig.size(); ++i)
{
string orig2 = orig;
orig2.erase(i, 1);
string perm2 = perm;
perm2 += orig.at(i);
string_permutation(orig2, perm2);
}
}
int main()
{
string orig = "ter";
string perm;
string_permutation(orig, perm);
return 0;
}
#include <string>
#include <iostream>
using namespace std;
void string_permutation( string& orig, string& perm )
{
if (orig.empty())
{
cout<<perm<<endl;
return;
}
for (int i = 0; i < orig.size(); ++i)
{
string orig2 = orig;
orig2.erase(i, 1);
string perm2 = perm;
perm2 += orig.at(i);
string_permutation(orig2, perm2);
}
}
int main()
{
string orig = "ter";
string perm;
string_permutation(orig, perm);
return 0;
}
57. What type of class template is list?
58. Pick out the correct statement about vector.
59. How do define the user-defined exceptions?
60. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> first;
first.assign (7,100);
vector<int>::iterator it;
it=first.begin()+1;
int myints[] = {1776,7,4};
cout << int (first.size()) << '\n';
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> first;
first.assign (7,100);
vector<int>::iterator it;
it=first.begin()+1;
int myints[] = {1776,7,4};
cout << int (first.size()) << '\n';
return 0;
}
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