81. 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)
{
cerr << 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)
{
cerr << msg << endl;
}
return 0;
}82. If inner catch block is unable to handle the exception thrown then . . . . . . . .
83. Where are allocators used?
84. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template<class T = float, int i = 5> class A
{
public:
A();
int value;
};
template<> class A<>
{
public: A();
};
template<> class A<double, 10>
{
public: A();
};
template<class T, int i> A<T, i>::A() : value(i)
{
cout << value;
}
A<>::A()
{
cout << "default";
}
A<double, 10>::A()
{
cout << "10" << endl;
}
int main()
{
A<int, 6> x;
A<> y;
A<double, 10> z;
}
#include <iostream>
using namespace std;
template<class T = float, int i = 5> class A
{
public:
A();
int value;
};
template<> class A<>
{
public: A();
};
template<> class A<double, 10>
{
public: A();
};
template<class T, int i> A<T, i>::A() : value(i)
{
cout << value;
}
A<>::A()
{
cout << "default";
}
A<double, 10>::A()
{
cout << "10" << endl;
}
int main()
{
A<int, 6> x;
A<> y;
A<double, 10> z;
}85. What is the use of checked iterators?
86. Which word is used to stop the unpacking of a value in a tuple?
87. What will be the output of the following C++ code?
#include <iostream>
#include <iterator>
#include <list>
using namespace std;
int main ()
{
list<int> mylist;
for (int i = 0; i < 5; i++)
mylist.push_back (i * 20);
list<int> :: iterator first = mylist.begin();
list<int> :: iterator last = mylist.end();
cout << distance(first, last) << endl;
return 0;
}
#include <iostream>
#include <iterator>
#include <list>
using namespace std;
int main ()
{
list<int> mylist;
for (int i = 0; i < 5; i++)
mylist.push_back (i * 20);
list<int> :: iterator first = mylist.begin();
list<int> :: iterator last = mylist.end();
cout << distance(first, last) << endl;
return 0;
}88. Which is a constant defined in <cstdlib> header file?
89. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main ()
{
int a = 100;
double b = 3.14;
cout << a;
cout << endl;
cout << b << endl << a * b;
endl (cout);
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
int a = 100;
double b = 3.14;
cout << a;
cout << endl;
cout << b << endl << a * b;
endl (cout);
return 0;
}90. Which exception is thrown by dynamic_cast?
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 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
