adplus-dvertising
frame-decoration

Question

What is the output of the program?
    #include <iostream>
    using namespace std;
    class Rect
    {
        int x, y;
        public:
        void set_values (int,int);
        int area ()
        {
            return (x * y);
        }
    };
    void Rect::set_values (int a, int b) 
    {
        x = a;
        y = b;
    }
    int main ()
    {
        Rect recta, rectb;
        recta.set_values (5, 6);
        rectb.set_values (7, 6);
        cout << "recta area: " << recta.area();
        cout << "rectb area: " << rectb.area();
        return 0;
    }

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: (a).recta area: 30 rectb area: 42

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 the program?