Sail E0 Webinar
Question


What is the output of the program?


1.
#include
2.
using namespace std;
3.
class Rect
4.
{
5.
int x, y;
6.
public:
7.
void set_values (int,int);
8.
int area ()
9.
{
10.
return (x * y);
11.
}
12.
};
13.
void Rect::set_values (int a, int b) {
14.
x = a;
15.
y = b;
16.
}
17.
int main ()
18.
{
19.
Rect recta, rectb;
20.
recta.set_values (5, 6);
21.
rectb.set_values (7, 6);
22.
cout << "recta area: " << recta.area();
23.
cout << "rectb area: " << rectb.area();
24.
return 0;
25.
}
Options:
A .  recta area: 30 rectb area: 42
B .  recta area: 20 rectb area: 34
C .  recta area: 30 rectb area: 21
D .  none of the mentioned
Answer: Option A

We are calculating the area of rectangle by two objects.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers