Select an option to see the answer and solution.
Standard Template Library (STL) in C++
practice.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
109
Questions
5/6
Page
Pick an option on a question to see the right answer and solution.
Select an option to see the answer and solution.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[] = {10, 20, 30, 30, 20, 10, 10, 20};
int mycount = count (myints, myints + 8, 10);
cout << "10 appears " << mycount << " times.\n";
vector<int> myvector (myints, myints+8);
mycount = count (myvector.begin(), myvector.end(), 20);
cout << "20 appears " << mycount << " times.\n";
return 0;
}Select an option to see the answer and solution.
#include <stdio.h>
#include <stdlib.h>
int main ()
{
div_t divresult;
divresult = div (38, 5);
printf ("%d\n", divresult.rem);
return 0;
}Select an option to see the answer and solution.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector (4);
fill (myvector.begin(), myvector.begin() + 2, 3);
fill (myvector.begin() + 1, myvector.end() - 1, 4);
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
#include <typeinfo>
#include <iostream>
using namespace std;
class Test
{
public:
Test();
virtual ~Test();
};
int main()
{
Test *ptrvar = NULL;
try
{
cout << typeid(*ptrvar).name() << endl;
}
catch (bad_typeid)
{
cout << "The object is null" << endl;
}
return 0;
}Select an option to see the answer and solution.
#include <iostream>
#include <algorithm>
using namespace std;
int main ()
{
int myints[] = {10, 20, 30, 30, 20, 10, 10, 20};
int* pbegin = myints;
int* pend = myints + sizeof(myints) / sizeof(int);
pend = remove (pbegin, pend, 20);
for (int* p = pbegin; p != pend; ++p)
cout << ' ' << *p;
return 0;
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int first[] = {5, 10, 15, 20, 25};
int second[] = {50, 40, 30, 20, 10};
vector<int> v(10);
vector<int> :: iterator it;
sort (first, first + 5);
sort (second, second + 5);
it = set_union (first, first + 5, second, second + 5, v.begin());
cout << int(it - v.begin());
return 0;
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int n, m;
n = abs(23);
m = abs(-11);
printf ("%d", n);
printf ("%d", m);
return 0;
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
#include <stdio.h>
#include <math.h>
int main ()
{
double param, result;
param = 5.5;
result = log (param);
printf ("%lf", result );
return 0;
}Select an option to see the answer and solution.
Q100
Open questionSelect an option to see the answer and solution.