Q201
Open questionSelect an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
1,008
Questions
11/51
Page
Pick an option on a question to see the right answer and solution.
Q201
Open questionSelect an option to see the answer and solution.
Q202
Open question#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;
}Select an option to see the answer and solution.
Q203
Open question#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;
}Select an option to see the answer and solution.
Q204
Open question#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;
}Select an option to see the answer and solution.
Q205
Open questionSelect an option to see the answer and solution.
Q206
Open questionSelect an option to see the answer and solution.
Q207
Open question#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;
}Select an option to see the answer and solution.
Q208
Open question#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;
}Select an option to see the answer and solution.
Q209
Open question#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;
}Select an option to see the answer and solution.
Q210
Open question#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;
}Select an option to see the answer and solution.
Q211
Open questionSelect an option to see the answer and solution.
Q212
Open questionSelect an option to see the answer and solution.
Q213
Open question#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;
}Select an option to see the answer and solution.
Q214
Open question#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;
}Select an option to see the answer and solution.
Q215
Open questionSelect an option to see the answer and solution.
Q216
Open questionSelect an option to see the answer and solution.
Q217
Open questionSelect an option to see the answer and solution.
Q218
Open questionSelect an option to see the answer and solution.
Q219
Open questionSelect an option to see the answer and solution.
Q220
Open questionSelect an option to see the answer and solution.