31. Which container provides random access iterators?
32. What will be the output of the following C++ code?
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
for (int i = 1; i < 4; ++i)
myvector.push_back(i*10);
ostream_iterator<int> out_it (cout,", ");
copy ( myvector.begin(), myvector.end(), out_it );
return 0;
}
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
for (int i = 1; i < 4; ++i)
myvector.push_back(i*10);
ostream_iterator<int> out_it (cout,", ");
copy ( myvector.begin(), myvector.end(), out_it );
return 0;
}33. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
double division(int a, int b)
{
if ( b == 0 )
{
throw "Division by zero condition!";
}
return (a / b);
}
int main ()
{
int x = 50;
int y = 0;
double z = 0;
try
{
z = division(x, y);
cout << z << endl;
}
catch (const char* msg)
{
cout << msg << endl;
}
return 0;
}
#include <iostream>
using namespace std;
double division(int a, int b)
{
if ( b == 0 )
{
throw "Division by zero condition!";
}
return (a / b);
}
int main ()
{
int x = 50;
int y = 0;
double z = 0;
try
{
z = division(x, y);
cout << z << endl;
}
catch (const char* msg)
{
cout << msg << endl;
}
return 0;
}34. What will be the output of the following C++ code?
#include <iostream>
#include <Valarray>
using namespace std;
int main()
{
Valarray<int> varr = { 1, 2, 3, 4, 5 };
for (int &x: varr) cout << x << " ";
cout<<endl;
varr = varr.cshift(-3);
for (int &x: varr) cout << x << " ";
return 0;
}
#include <iostream>
#include <Valarray>
using namespace std;
int main()
{
Valarray<int> varr = { 1, 2, 3, 4, 5 };
for (int &x: varr) cout << x << " ";
cout<<endl;
varr = varr.cshift(-3);
for (int &x: varr) cout << x << " ";
return 0;
}35. Which function is used to check whether a character is an alphabet?
36. What happens when no argument is supplied to reset() function?
37. How many template parameters are allowed in template classes?
38. Which is also called as abstract class?
39. What is vtable in C++?
40. What is vptr?
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 1
- 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 10
- C plus plus miscellaneous - Section 11
