Cpp Programming Quiz 218 – What will be the output of the following program?
[A].
3
[B].4
[C].
5
[D].
Garbage-value
Answer: Option B
Explanation:
No answer description available for this question.
5
[D].
Garbage-value
Answer: Option B
Explanation:
No answer description available for this question.
Answer: Option B
Answer: Option C
#include
static double gDouble;
static float gFloat;
static double gChar;
static double gSum = 0;
class BaseOne
{
public:
void Display(double x = 0.0, float y = 0.0, char z = 'A')
{
gDouble = x;
gFloat = y;
gChar = int(z);
gSum = gDouble + gFloat + gChar;
cout << gSum;
}
};
class BaseTwo
{
public:
void Display(int x = 1, float y = 0.0, char z = 'A')
{
gDouble = x;
gFloat = y;
gChar = int(z);
gSum = gDouble + gFloat + gChar;
cout << gSum;
}
};
class Derived : public BaseOne, BaseTwo
{
void Show()
{
cout << gSum;
}
};
int main()
{
Derived objDev;
objDev.BaseTwo::Display(10, 20, 'Z');
return 0;
}
[A].The program will print the output 0.
[B].The program will print the output 120.
[C].The program will report run-time error.
[D].The program will report compile-time error.
Answer: Option D
#include
class India
{
public:
struct Bix
{
int x;
float y;
void Function(void)
{
y = x = (x = 4*4);
y = --y * y;
}
void Display()
{
cout<< y << endl;
}
}B;
}I;
int main()
{
I.B.Display();
return 0;
}
[A].0
[B].1
[C].-1
[D].Garbage value
Answer: Option A
Answer: Option C
#include
class BixBase
{
int x, y;
public:
BixBase(int xx = 10, int yy = 10)
{
x = xx;
y = yy;
}
void Show()
{
cout<< x * y << endl;
}
};
class BixDerived : public BixBase
{
private:
BixBase objBase;
public:
BixDerived(int xx, int yy) : BixBase(xx, yy), objBase(yy, yy)
{
objBase.Show();
}
};
int main()
{
BixDerived objDev(10, 20);
return 0;
}
[A].The program will print the output 100.
[B].The program will print the output 200.
[C].The program will print the output 400.
[D].The program will print the output Garbage-value.
Answer: Option C