Question 1 of 25
Hints left: 3
Q1
What is the use of rank() function in C++?
Q2
What is meant by garbage collection?
Q3
What will be the output of the following C++ code? #include <iostream> #include <map> using namespace std; int main () { multimap<char, int> mymultimap; mymultimap.insert(make_pair('x', 100)); mymultimap.insert(make_pair('y', 200)); mymultimap.insert(make_pair('y', 350)); mymultimap.insert(make_pair('z', 500)); cout << mymultimap.size() << '\n'; return 0; }
Q4
What is the property of stable sort function provided by the STL algorithm?
Q5
Which function is used to insert an element into heap?
Q6
Which are not full container classes in c++?
Q7
What is the use of proj() function?
Q9
What will be the output of the following C++ code? #include <iostream> using namespace std; int funcstatic(int) { int sum = 0; sum = sum + 10; return sum; } int main(void) { int r = 5, s; s = funcstatic(r); cout << s << endl; return 0; }
Q10
Pick out the correct option.
Q11
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.capacity()<<endl; v.shrink_to_fit(); cout<<v.capacity()<<endl; return 0; }
Q12
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<<arg(cn)<<endl; return 0; }
Q13
What will be the output of the following C++ code? #include <iostream> #include <string> #include <tuple> using namespace std; int main() { tuple <int, char, string> tp; tp = make_tuple(4, '1', "Hello"); cout<<get<0>(tp)<<endl; cout<<get<1>(tp)<<endl; cout<<get<2>(tp)<<endl; return 0; }
Q14
What will be the output of the following C++ code? #include <iostream> #include <vector> using namespace std; int main () { vector<int> myvector; int sum (0); myvector.push_back (100); myvector.push_back (200); myvector.push_back (300); while (!myvector.empty()) { sum += myvector.back(); myvector.pop_back(); } cout << sum << '\n'; return 0; }
Q15
What will be the output of the following C++ code? #include <iostream> #include <typeinfo> using namespace std; class A { }; int main() { char c; float x; if (typeid(c) != typeid(x)) cout << typeid(c).name() << endl; cout << typeid(A).name(); return 0; }
Q16
What will be the output of the following C++ code? #include <iostream> #include <new> #include <cstdlib> using namespace std; const int bsize = 512; int *pa; bool allocate = true; void get_memory() { cerr << "free store exhausted" << endl; delete [] pa; allocate = false; } void eat_memory(int size) { int *p = new int[size]; if (allocate) eat_memory(size); else cerr << "free store addr = " << p << endl; } int main() { set_new_handler(get_memory); pa = new int[bsize]; cerr << "free store addr = " << pa << endl; eat_memory(bsize); return 0; }
Q17
Choose the correct formatted code.
Q18
What will be the output of the following C++ code? #include <iostream> using namespace std; template <class T, int max> int arrMin(T arr[], int n) { int m = max; for (int i = 0; i < n; i++) if (arr[i] < m) m = arr[i]; return m; } int main() { int arr1[] = {10, 20, 15, 12}; int n1 = sizeof(arr1)/sizeof(arr1[0]); char arr2[] = {1, 2, 3}; int n2 = sizeof(arr2)/sizeof(arr2[0]); cout << arrMin<int, 10000>(arr1, n1) << endl; cout << arrMin<char, 256>(arr2, n2); return 0; }
Q19
What will be the output of the following C++ code? #include <iostream> using namespace std; void Sum(int a, int b, int & c) { a = b + c; b = a + c; c = a + b; } int main() { int x = 2, y =3; Sum(x, y, y); cout << x << " " << y; return 0; }
Q20
What is a pure virtual function in C++?
Q21
Which type of relationship is modelled by Composition?
Q22
What is the use of apply() function in Valarray?
Q23
Which function is used to get the total capacity of a vector?
Q24
What will be the output of the following C++ code? #include <iostream> #include <array> using namespace std; int main(int argc, char const *argv[]) { array<int,10> arr = {1,2,3,4,5}; cout<<"size:"<<arr.size()<<endl; cout<<"maxsize:"<<arr.max_size()<<endl; return 0; }
Q25
What is the operation for .*?