71. What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int main()
{
int x = 5;
auto check = []() -> bool
{
if(x == 0)
return false;
else
return true;
};
cout<<check()<<endl;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int x = 5;
auto check = []() -> bool
{
if(x == 0)
return false;
else
return true;
};
cout<<check()<<endl;
return 0;
}
72. What do all STL containers define?
73. 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);
vector<int> :: const_iterator i;
i = v.begin();
*i = 3;
for (i = v.begin(); i != v.end(); ++i)
cout << *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);
vector<int> :: const_iterator i;
i = v.begin();
*i = 3;
for (i = v.begin(); i != v.end(); ++i)
cout << *i << " ";
cout<<endl;
return 0;
}
74. Which function is used to return the minimum element in the range?
75. What will be the output of the following C++ code?
#include <iostream>
#include <complex>
using namespace std;
int main()
{
complex <double> cn(3.0, 5.0);
cout<<"Absolute value is: "<<abs(cn)<<endl;
return 0;
}
#include <iostream>
#include <complex>
using namespace std;
int main()
{
complex <double> cn(3.0, 5.0);
cout<<"Absolute value is: "<<abs(cn)<<endl;
return 0;
}
76. What will be the output of the following C++ code?
#include <iostream>
#include <typeinfo>
#include <exception>
using namespace std;
class base
{
virtual void f(){}
};
class derived : public base {};
int main ()
{
try
{
base* a = new base;
base* b = new derived;
cout << typeid(*a).name() <v '\t';
cout << typeid(*b).name();
}
catch (exception& e)
{
cout << "Exception: " << e.what() << endl;
}
return 0;
}
#include <iostream>
#include <typeinfo>
#include <exception>
using namespace std;
class base
{
virtual void f(){}
};
class derived : public base {};
int main ()
{
try
{
base* a = new base;
base* b = new derived;
cout << typeid(*a).name() <v '\t';
cout << typeid(*b).name();
}
catch (exception& e)
{
cout << "Exception: " << e.what() << endl;
}
return 0;
}
77. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
virtual void func() = 0;
};
class B: public A
{
public:
void func(){
cout<<"Class B"<<endl;
}
};
int main(int argc, char const *argv[])
{
B b;
b.func();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
virtual void func() = 0;
};
class B: public A
{
public:
void func(){
cout<<"Class B"<<endl;
}
};
int main(int argc, char const *argv[])
{
B b;
b.func();
return 0;
}
78. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[] = {1, 2, 3, 4 ,5};
vector<int> v(myints, myints + 5);
v.push_back(33);
push_heap (v.begin(),v.end());
cout << v.front() << '\n';
sort_heap (v.begin(),v.end());
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[] = {1, 2, 3, 4 ,5};
vector<int> v(myints, myints + 5);
v.push_back(33);
push_heap (v.begin(),v.end());
cout << v.front() << '\n';
sort_heap (v.begin(),v.end());
return 0;
}
79. What does the sequence adaptor provide?
80. Which statement is used to catch all types of exceptions?
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 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