Sail E0 Webinar
Question


What is the output of this program?


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

In this program, we are calculating the area of rectangle based on given values.
Output:
$ g++ class.cpp
$ a.out
rect area: 12



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers