Q141
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
8/51
Page
Pick an option on a question to see the right answer and solution.
Q141
Open questionSelect an option to see the answer and solution.
Q142
Open questionSelect an option to see the answer and solution.
Q143
Open question#include <iostream>
using namespace std;
template <class T>
T max (T& a, T& b)
{
return (a>b?a:b);
}
int main ()
{
int i = 5, j = 6, k;
long l = 10, m = 5, n;
k = max(i, j);
n = max(l, m);
cout << k << endl;
cout << n << endl;
return 0;
}Select an option to see the answer and solution.
Q144
Open questionSelect an option to see the answer and solution.
Q145
Open questionSelect an option to see the answer and solution.
Q146
Open questionSelect an option to see the answer and solution.
Q147
Open question==================
template<class T>
T func(T a)
{
cout<<a;
}
==================Select an option to see the answer and solution.
Q148
Open questionSelect an option to see the answer and solution.
Q149
Open questionSelect an option to see the answer and solution.
Q150
Open questionSelect an option to see the answer and solution.
Q151
Open questionSelect an option to see the answer and solution.
Q152
Open questionSelect an option to see the answer and solution.
Q153
Open questionSelect an option to see the answer and solution.
Q154
Open question#include <iostream>
using namespace std;
struct A
{
private:
int i, j, k;
public:
int f();
void g();
};
int A :: f()
{
return i + j + k;
}
void A :: g()
{
i = j = k = 0;
}
class B
{
int i, j, k;
public:
int f();
void g();
};
int B :: f()
{
return i + j + k;
}
void B :: g()
{
i = j = k = 0;
}
int main()
{
A a;
B b;
a.f();
a.g();
b.f();
b.g();
cout << "Identical results would be produced";
}Select an option to see the answer and solution.
Q155
Open questionSelect an option to see the answer and solution.
Q156
Open question#include <iostream>
#include <cmath>
#include <list>
using namespace std;
bool same_integral_part (double first, double second)
{
return ( int(first) == int(second) );
}
struct is_near
{
bool operator() (double first, double second)
{
return (fabs(first - second) < 5.0);
}
};
int main ()
{
double mydoubles[] = { 12.15, 2.72, 73.0, 12.77, 3.14, 12.77, 73.35, 72.25, 15.3, 72.25 };
list<double> mylist (mydoubles, mydoubles + 10);
mylist.sort();
mylist.unique();
mylist.unique (same_integral_part);
mylist.unique (is_near());
for (list<double> :: iterator it = mylist.begin(); it != mylist.end(); ++it)
cout << ' ' << *it;
cout << '\n';
return 0;
}Select an option to see the answer and solution.
Q157
Open questionSelect an option to see the answer and solution.
Q158
Open questionSelect an option to see the answer and solution.
Q159
Open question#include<iostream>
#include<any>
using namespace std;
int main()
{
float val = 5.5;
any var(val);
cout<<any_cast<float>(var)<<endl;
var.reset();
if(!var.has_value())
{
cout<<"var is empty\n";
}
else{
cout<<"var is not empty\n";
}
return 0;
}Select an option to see the answer and solution.
Q160
Open questionSelect an option to see the answer and solution.