Advertisement Area

Program #15: To Calculate the Area of Rectangle using Constructor

C++ Language

#include<iostream.h>
#include<conio.h>
class rectangle
{
    private:
    int l,b,area;
    
    public:
    rectangle()
    {
        cout<<"Enter the Length and Breadth - "<<endl;
        cin>>l>>b;
        area=l*b;
        cout<<"Area - "<<area;
    }
};
void main()
{
    clrscr();
    rectangle obj;
    getch();
}


/*OUTPUT*/
Enter the Length and Breadth - 
10
20
Area - 200