Q301
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
16/51
Page
Pick an option on a question to see the right answer and solution.
Q301
Open questionSelect an option to see the answer and solution.
Q302
Open question#include <iostream>
using namespace std;
template <typename T = float, int count = 3>
T multIt(T x)
{
for(int ii = 0; ii < count; ii++)
{
x = x * x;
}
return x;
};
int main()
{
float xx = 2.1;
cout << xx << ": " << multIt<>(xx) << endl;
}Select an option to see the answer and solution.
Q303
Open question#include<iostream>
using namespace std;
int main()
{
int a = 5;
auto check = [=]()
{
a = 10;
};
check();
cout<<"Value of a: "<<a<<endl;
return 0;
}Select an option to see the answer and solution.
Q304
Open question#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> first (5, 10);
vector<int> second (5, 33);
vector<int>::iterator it;
swap_ranges(first.begin() + 1, first.end() - 1, second.begin());
cout << " first contains:";
for (it = first.begin(); it != first.end(); ++it)
cout << " " << *it;
cout << "\nsecond contains:";
for (it = second.begin(); it != second.end(); ++it)
cout << " " << *it;
return 0;
}Select an option to see the answer and solution.
Q305
Open question#include <vector>
#include <iostream>
#include <typeinfo>
#include <stdexcept>
using namespace std;
int main()
{
vector<int> vec;
vec.push_back(10);
int i = vec[100];
try {
i = vec[0];
cout << i << endl;
}
catch (exception &e)
{
cout << "Caught: " << e.what( ) << endl;
cout << "Type: " << typeid( e ).name( ) << endl;
}
catch (...)
{
cout << "Unknown exception: " << endl;
}
return 0;
}Select an option to see the answer and solution.
Q306
Open questionSelect an option to see the answer and solution.
Q307
Open questionSelect an option to see the answer and solution.
Q308
Open question#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
bool mypredicate (int i, int j)
{
return (i == j);
}
int main ()
{
vector<int> myvector;
for (int i = 1; i < 6; i++) myvector.push_back (i * 10);
int myints[] = {10, 20, 30, 40, 1024};
pair<vector<int> :: iterator, int*> mypair;
mypair = mismatch (myvector.begin(), myvector.end(), myints);
cout << *mypair.first<<'\n';
cout << *mypair.second << '\n';
++mypair.first; ++mypair.second;
return 0;
}Select an option to see the answer and solution.
Q309
Open question#include <iostream>
#include <memory>
#include <string>
using namespace std;
int main ()
{
pair <string*, ptrdiff_t>
result = get_temporary_buffer<string>(3);
if (result.second > 0)
{
uninitialized_fill ( result.first, result.first + result.second,
"Hai" );
for (int i=0; i<result.second; i++)
cout << result.first[i] ;
return_temporary_buffer(result.first);
}
return 0;
}Select an option to see the answer and solution.
Q310
Open questionSelect an option to see the answer and solution.
Q311
Open questionSelect an option to see the answer and solution.
Q312
Open question#include <iostream>
using namespace std;
int main( )
{
char line[100];
cin.getline( line, 100, 't' );
cout << line;
return 0;
}Select an option to see the answer and solution.
Q313
Open questionSelect an option to see the answer and solution.
Q314
Open questionSelect an option to see the answer and solution.
Q315
Open questionSelect an option to see the answer and solution.
Q316
Open question#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
char arr[27] = "abcdefghijklmnopqrstuvwxyz";
for(int i=0;i<27;i++)
{
cout<<(bool)isxdigit(arr[i]);
}
}Select an option to see the answer and solution.
Q317
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.size();
cout<<endl<<v.capacity();
return 0;
}Select an option to see the answer and solution.
Q318
Open question#include <iostream>
using namespace std;
template <class type>
class Test
{
public:
Test()
{
};
~Test()
{
};
type Funct1(type Var1)
{
return Var1;
}
type Funct2(type Var2)
{
return Var2;
}
};
int main()
{
Test<int> Var1;
Test<double> Var2;
cout << Var1.Funct1(200);
cout << Var2.Funct2(3.123);
return 0;
}Select an option to see the answer and solution.
Q319
Open questionSelect an option to see the answer and solution.
Q320
Open questionSelect an option to see the answer and solution.