Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> #include <string> #include <bitset> using namespace std; int main () { string mystring; bitset<4> mybits; mybits.set(); mystring = mybits.to_string<char, char_traits<char>, allocator<char> >(); cout << mystring << endl; return 0; }
Q2
How many kinds of entities are directly parameterized in c++?
Q3
What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main () { vector<bool> mask; mask.push_back(true); mask.flip(); cout << boolalpha; for (unsigned i = 0; i < mask.size(); i++) cout << mask.at(i); return 0; }
Q4
What do you mean by "No exception specification"?
Q5
What will be the output of the following C++ code? #include<iostream> #include<any> #include<string> using namespace std; int main() { string s = "Hello World"; any var(s); cout<<any_cast<string>(var)<<endl; return 0; }
Q6
What will be the output of the following C++ code? #include <iostream> using namespace std; struct A { private: int i, j, k; public: int f(); void g(); }; int A :: f() { return i + j + k; } void A :: g() { i = j = k = 0; } class B { int i, j, k; public: int f(); void g(); }; int B :: f() { return i + j + k; } void B :: g() { i = j = k = 0; } int main() { A a; B b; a.f(); a.g(); b.f(); b.g(); cout << "Identical results would be produced"; }
Q7
What does the second parameter of the main function represent?
Q8
Which are the parameters for the content of the buffer?
Q9
What will be the output of the following C++ code? #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(int argc, char const *argv[]) { vector <int> v = {1,5,23,90,15,35}; make_heap(v.begin(),v.end()); v.push_back(110); push_heap(v.begin(), v.end()); pop_heap(v.begin(), v.end()); v.pop_back(); cout<<v.front(); }
Q10
What does this template function indicates? ================== template<class T> T func(T a) { cout<<a; } ==================
Q11
Which operations don't throw anything?
Q12
vptr is . . . . . . . .
Q14
Which header file is required for using Valarray?
Q15
What will be the output of the following C++ code? #include <iostream> #include <string> #include <cstdlib> using namespace std; template<class T> T func(T a) { cout<<a; return a; } template<class U> void func(U a) { cout<<a; } int main(int argc, char const *argv[]) { int a = 5; int b = func(a); return 0; }
Q16
What is linear_congruential_engine?
Q17
What will be the output of the following C++ code? #include <iostream> #include <cmath> #include <list> using namespace std; bool same_integral_part (double first, double second) { return ( int(first) == int(second) ); } struct is_near { bool operator() (double first, double second) { return (fabs(first - second) < 5.0); } }; int main () { double mydoubles[] = { 12.15, 2.72, 73.0, 12.77, 3.14, 12.77, 73.35, 72.25, 15.3, 72.25 }; list<double> mylist (mydoubles, mydoubles + 10); mylist.sort(); mylist.unique(); mylist.unique (same_integral_part); mylist.unique (is_near()); for (list<double> :: iterator it = mylist.begin(); it != mylist.end(); ++it) cout << ' ' << *it; cout << '\n'; return 0; }
Q18
What kind of exceptions are available in c++?
Q19
What do associate containers implement?
Q20
Which container is best to keep the collection of distinct elements?
Q21
What operation can be performed by destructor?
Q22
Which function is used to get the imaginary part of the complex number?
Q23
Which header file is used to manipulate the vector algebra in c++?
Q24
How many types of loops are there in C++?
Q25
What will be the output of the following C++ code? #include<iostream> #include<any> using namespace std; int main() { float val = 5.5; any var(val); cout<<any_cast<float>(var)<<endl; var.reset(); if(!var.has_value()) { cout<<"var is empty\n"; } else{ cout<<"var is not empty\n"; } return 0; }