41. What is meant by heap?
42. What will be the output of the following C++ code?
#include <iostream>
#include <iomanip>
using namespace std;
void showDate(int m, int d, int y)
{
cout << setfill('0');
cout << setw(2) << m << '/'
<< setw(2) << d << '/'
<< setw(4) << y << endl;
}
int main()
{
showDate(1, 1, 2013);
return 0;
}
#include <iostream>
#include <iomanip>
using namespace std;
void showDate(int m, int d, int y)
{
cout << setfill('0');
cout << setw(2) << m << '/'
<< setw(2) << d << '/'
<< setw(4) << y << endl;
}
int main()
{
showDate(1, 1, 2013);
return 0;
}43. What is the benefit of c++ input and output over c input and output?
44. What will happen if the iterator is unchecked?
45. What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T, class U = char>
class A
{
T a;
U b;
public:
A(T a_val, char b_val = '$'){
this->a = a_val;
this->b = b_val;
}
void print(){
cout<<a<<' '<<b<<endl;
}
};
int main(int argc, char const *argv[])
{
A <int, int> a1(5,10);
A <int> a2(5);
A <float> a3(10.0);
a1.print();
a2.print();
a3.print();
return 0;
}
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T, class U = char>
class A
{
T a;
U b;
public:
A(T a_val, char b_val = '$'){
this->a = a_val;
this->b = b_val;
}
void print(){
cout<<a<<' '<<b<<endl;
}
};
int main(int argc, char const *argv[])
{
A <int, int> a1(5,10);
A <int> a2(5);
A <float> a3(10.0);
a1.print();
a2.print();
a3.print();
return 0;
}46. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void Division(const double a, const double b);
int main()
{
double op1=0, op2=10;
try
{
Division(op1, op2);
}
catch (const char* Str)
{
cout << "\nBad Operator: " << Str;
}
return 0;
}
void Division(const double a, const double b)
{
double res;
if (b == 0)
throw "Division by zero not allowed";
res = a / b;
cout << res;
}
#include <iostream>
using namespace std;
void Division(const double a, const double b);
int main()
{
double op1=0, op2=10;
try
{
Division(op1, op2);
}
catch (const char* Str)
{
cout << "\nBad Operator: " << Str;
}
return 0;
}
void Division(const double a, const double b)
{
double res;
if (b == 0)
throw "Division by zero not allowed";
res = a / b;
cout << res;
}47. What will be the output of the following C++ code?
#include <iostream>
#include <functional>
#include <numeric>
using namespace std;
int myaccumulator (int x, int y)
{
return x - y;
}
int myproduct (int x, int y)
{
return x + y;
}
int main ()
{
int a = 100;
int series1[] = {10, 20, 30};
int series2[] = {1, 2, 3};
cout << inner_product(series1, series1 + 3, series2, a ,myaccumulator,
myproduct);
cout << endl;
return 0;
}
#include <iostream>
#include <functional>
#include <numeric>
using namespace std;
int myaccumulator (int x, int y)
{
return x - y;
}
int myproduct (int x, int y)
{
return x + y;
}
int main ()
{
int a = 100;
int series1[] = {10, 20, 30};
int series2[] = {1, 2, 3};
cout << inner_product(series1, series1 + 3, series2, a ,myaccumulator,
myproduct);
cout << endl;
return 0;
}48. Which function is used to access the first element of an array class?
49. What will the max function in the numeric limit will return for type float?
50. What should be used to point to a static class member?
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
