Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> #include <list> using namespace std; int main () { list<int> mylist; list<int> :: iterator it1, it2; for (int i = 1; i < 10; ++i) mylist.push_back(i * 1); it1 = it2 = mylist.begin(); advance (it2, 6); ++it1; it1 = mylist.erase (it1); it2 = mylist.erase (it2); ++it1; --it2; mylist.erase (it1, it2); for (it1 = mylist.begin(); it1 != mylist.end(); ++it1) cout << ' ' << *it1; return 0; }
Q2
Which of the following(s) is/are the correct way of assigning values to a forward_list f?
-
A
-
B
-
C
-
D
Q3
What will be the output of the following C++ code? #include <iostream> #include <limits> using namespace std; int main( ) { cout << numeric_limits<float> :: min_exponent << endl; }
Q4
What are Engine Adaptors?
Q5
What is meant by type_info?
Q6
What is the use of is_same() function in C++?
Q7
Which of the following is correct about tuple_size?
Q8
What will be the output of the following C++ code? #include <iostream> #include <vector> #include <forward_list> using namespace std; int main() { forward_list<int> fl1; fl1.assign(5,10); for (int&c : fl1) cout << c << " "; cout<<endl; fl1.insert_after(fl1.begin(), {1,2,3}); for (int&c : fl1) cout << c << " "; cout<<endl; return 0; }
Q9
Which is used to check the error in the block?
Q10
What will be the output of the following C++ code? #include <iostream> #include <algorithm> using namespace std; int main () { cout << min(2, 1) << ' '; cout << min('m','m') << '\n'; return 0; }
Q11
How many parameters does the throw expression can have?
Q12
How many parameters are required for next_permutation?
Q13
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); cout<<v.size()<<endl; v.resize(4); cout<<v.size()<<endl; return 0; }
Q14
Which of the following syntax is used to convert any variable to its original type?
Q15
Which value is pointed out first in heap?
Q16
Which of the following keyword is used to declare the header file?
Q17
How to protect the heap from affecting the memory?
Q18
What will be the output of the following C++ code? #include <cstdlib> #include <iostream> using namespace std; class X { public: void* operator new(size_t sz) throw (const char*) { void* p = malloc(sz); if (p == 0) throw "malloc() failed"; return p; } void operator delete(void* p) { cout << "X :: operator delete(void*)" << endl; free(p); } }; class Y { int filler[100]; public: void operator delete(void* p, size_t sz) throw (const char*) { cout << "Freeing " << sz << " bytes" << endl; free(p); }; }; int main() { X* ptr = new X; delete ptr; Y* yptr = new Y; delete yptr; }
Q19
What will be the output of the following C++ code? #include <vector> #include <algorithm> #include <iostream> using namespace std; int main() { vector<int> v(10, 2); if (all_of(v.cbegin(), v.cend(), [](int i){ return i % 2 == 0; })) { cout << "All numbers are even\n"; } else { cout << "All numbers are not even\n"; } return 0; }
Q20
What type of reference should be used in vector arithmetic?
Q21
What will be the output of the following C++ code? #include <iostream> using namespace std; class Base { public: Base(){} ~Base(){} protected: private: }; class Derived:public Base { public: Derived(){} Derived(){} private: protected: }; int main() { cout << "The program exceuted" << endl; }
Q22
Which is the correct syntax of capturing a variable 'X' by reference and other variable 'Y' by value in lambda expression?
Q23
How the list containers are implemented?
Q24
Which of the following is a Non-modifying Sequence Operation?
Q25
What will be the output of the following C++ code? #include <iostream> #include<type_traits> using namespace std; class Base { public: void function1() {}; void function2() {}; }; int main() { Base b; cout<<sizeof(b); return 0; }