adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class rect
    {
        int x, y;
        public:
        void val (int, int);
        int area ()
        {
            return (x * y);
        }
    };
    void rect::val (int a, int b)
    {
        x = a;
        y = b;
    }
    int main ()
    {
        rect rect;
        rect.val (3, 4);
        cout << "rect area: " << rect.area();
        return 0;
    }

a.

rect area:7

b.

rect area: 12

c.

rect area:24

d.

none of the mentioned

Answer: (b).rect area: 12

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?