Q101
Open question#include <iostream>
using namespace std;
int main()
{
typedef int num;
num a = 10, b = 15;
num c = a + b + a - b;
cout << c;
return 0;
}Select an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
251
Questions
6/13
Page
Pick an option on a question to see the right answer and solution.
Q101
Open question#include <iostream>
using namespace std;
int main()
{
typedef int num;
num a = 10, b = 15;
num c = a + b + a - b;
cout << c;
return 0;
}Select an option to see the answer and solution.
Q102
Open questionSelect an option to see the answer and solution.
Q103
Open questionSelect an option to see the answer and solution.
Q104
Open question#include <iostream>
#include <string>
using namespace std;
class B
{
int b;
public:
B(int i){
b = i;
}
};
class C
{
B b;
public:
C(int i){
b = B(i);
}
friend void show();
};
void show()
{
C c(10);
cout<<"value of b is: "<<c.b.b<<endl;
}
int main(int argc, char const *argv[])
{
show();
return 0;
}Select an option to see the answer and solution.
Q105
Open question#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("nobody does like this");
string key ("nobody");
size_t f;
f = str.rfind(key);
if (f != string::npos)
str.replace (f, key.length(), "everybody");
cout << str << endl;
return 0;
}Select an option to see the answer and solution.
Q106
Open question---------------------------
Example class:
class A
{
public:
static int value;
}
---------------------------Select an option to see the answer and solution.
Q107
Open question#include <iostream>
using namespace std;
class myclass
{
public:
int i;
myclass *operator->()
{return this;}
};
int main()
{
myclass ob;
ob->i = 10;
cout << ob.i << " " << ob->i;
return 0;
}Select an option to see the answer and solution.
Q108
Open questionSelect an option to see the answer and solution.
Q109
Open questionSelect an option to see the answer and solution.
Q110
Open questionSelect an option to see the answer and solution.
Q111
Open question#include <iostream>
#include <complex>
using namespace std;
int main()
{
complex<double> c_double(2, 3);
complex<int> c_int(4, 5);
c_double *= 2;
c_double = c_int;
cout << c_double;
return 0;
}Select an option to see the answer and solution.
Q112
Open questionSelect an option to see the answer and solution.
Q113
Open questionSelect an option to see the answer and solution.
Q114
Open question#include <iostream>
using namespace std;
int operate (int a, int b)
{
return (a * b);
}
float operate (float a, float b)
{
return (a / b);
}
int main ()
{
int x = 5, y = 2;
float n = 5.0, m = 2.0;
cout << operate (x, y);
cout << operate (n, m);
return 0;
}Select an option to see the answer and solution.
Q115
Open question#include <iostream>
using namespace std;
class Box
{
public :
double length;
double breadth;
double height;
};
int main( )
{
Box Box1;
double volume;
Box1.height = 5;
Box1.length = 6;
Box1.breadth = 7.1;
volume = Box1.height * Box1.length * Box1.breadth;
cout << "Volume of Box1 : " << volume <<endl;
return 0;
}Select an option to see the answer and solution.
Q116
Open questionSelect an option to see the answer and solution.
Q117
Open questionSelect an option to see the answer and solution.
Q118
Open question#include <iostream>
using namespace std;
class sample
{
int width, height;
public:
void set_values (int, int);
int area () {return (width * height);}
friend sample duplicate (sample);
};
void sample::set_values (int a, int b)
{
width = a;
height = b;
}
sample duplicate (sample rectparam)
{
sample rectres;
rectres.width = rectparam.width * 2;
rectres.height = rectparam.height * 2;
return (rectres);
}
int main ()
{
sample rect, rectb;
rect.set_values (2, 3);
rectb = duplicate (rect);
cout << rectb.area();
return 0;
}Select an option to see the answer and solution.
Q119
Open questionSelect an option to see the answer and solution.
Q120
Open questionSelect an option to see the answer and solution.