Question 1 of 25
Hints left: 3
Q1
What is the use of the indentation in c++?
Q2
Which header file is required to use any container?
Q3
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; } int func(int a) { cout<<a; } int main(int argc, char const *argv[]) { int a = 5; int b = func(a); float c = func(5.5); return 0; }
Q4
Which of the header file must be included to use stringstream?
Q5
What type can be used to replace templates from this function? template<class T, class U> T func(T a, T b, U c) { if(c == '+' || c){ return a+b; } else if(c == '-' || !c){ return a-b; } }
Q6
Why is it expensive to use objects for the exception?
Q7
What will be the output of the following C++ code? #include <iostream> #include <set> using namespace std; int main () { multiset<int> mymultiset; for (int i = 0; i < 5; i++) mymultiset.insert(i); multiset<int> :: key_compare mycomp = mymultiset.key_comp(); int highest = *mymultiset.rbegin(); multiset<int> :: iterator it = mymultiset.begin(); do { cout << ' ' << *it; } while (mycomp(*it++, highest)); return 0; }
Q8
What is the use of count() function in bitset?
Q9
How can the member functions in the container be accessed?
Q10
Members of which access specifiers are not inherited?
Q11
What is the correct syntax for declaring an allocator?
Q12
What is meant by the template parameter?
Q13
What is Pseudo-random number engines?
Q14
Where does a cin stops it extraction of data?
Q15
How many parameters are available in the function setbuf?
Q16
What will be the output of the following C++ code? #include <stdio.h> int main () { freopen ("myfile.txt", "w", stdout); printf ("This sentence is redirected to a file"); fclose (stdout); return 0; }
Q17
To use internal linkage we have to use which keyword?
Q18
What will be the output of the following C++ code? #include <iostream> #include<string.h> using namespace std; int main() { try { char *p; strcpy(p, "How r u"); } catch(const exception& er) { } }
Q19
What will be the output of the following C++ code? #include <iostream> using namespace std; class Foo { public: Foo(int i = 0){ _i = i;} void f() { cout << "Executed"<<endl; } private: int _i; }; int main() { Foo *p = 0; p -> f(); }
Q20
What do we return if we use simple array on a internal container?
Q21
What will be the output of the following C++ code? #include <iostream> #include <typeinfo> using namespace std; int main () { int * a; int b; a = 0; b = 0; if (typeid(a) != typeid(b)) { cout << typeid(a).name(); cout << typeid(b).name(); } return 0; }
Q22
What will be the output of the following C++ code? #include <iostream> #include <limits> using namespace std; int main( ) { cout << numeric_limits<short int> :: max() << endl; }
Q23
Which function is used to optimize the space in vector?
Q24
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 < 10; i++) mylist.push_back (i * 10); list<int> :: iterator it = mylist.begin(); advance (it, 5); cout << *it << endl; return 0; }
Q25
What is the importance of mutable keyword?