Home » C++ Programming » Classes & Objects » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Rectangle
    {
    int p, q;
    public:
    void value (int, int);
    int area ()
    {
    return (p * q);
    }
    };
    void Rectangle::value (int n, int m)
    {
    p = n;
    q = m;
    }
    int main ()
    {
    Rectangle Rectangle;
    Rectangle.value (6, 5);
    cout << "Area of Rectangle : " << Rectangle.area();
    return 0;
    }
    1. Area of Rectangle : 30
    2. Area of Rectangle : 3
    3. Area of Rectangle : 4
    4. Compilation Error
    5. None of these
Correct Option: A

In this program, we are calculating the area of rectangle based on given values.



Your comments will be displayed only after manual approval.