1.

What is the output of this program?
#include <iostream>
using namespace std;
class Polygon
{
protected:
int W, H;
public:
void set_values(int width, int height)
{
W = width; H = height;
}
};
class Coutput
{
public:
void output(int i);
};
void Coutput::output(int i)
{
cout << i < }
class Rectangle:public Polygon, public Coutput
{
public:
int area()
{
return(W * H);
}
};
class Triangle:public Polygon, public Coutput
{
public:
int area()
{
return(W * H / 2);
}
};
int main()
{
Rectangle Rect;
Triangle trgl;
Rect.set_values(5, 2);
trgl.set_values(5, 2);
Rect.output(Rect.area());
trgl.output(trgl.area());
return 0;
}

A. 5 2
B. 2 5
C. 10 5
D. 5 10
E. None of these
Answer» D. 5 10


Discussion

No Comment Found

Related MCQs