0% found this document useful (0 votes)
19 views1 page

Simple Program

This C++ program defines a Rectangle class with length and breadth properties. It creates two Rectangle objects, rt1 with dimensions 7x4 and rt2 with 4x5. The program prints the area of each rectangle by calling the printArea method, which returns the product of length and breadth.

Uploaded by

amolia2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Simple Program

This C++ program defines a Rectangle class with length and breadth properties. It creates two Rectangle objects, rt1 with dimensions 7x4 and rt2 with 4x5. The program prints the area of each rectangle by calling the printArea method, which returns the product of length and breadth.

Uploaded by

amolia2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <iostream>

using namespace std;

class Rectangle
{
public:
int length;
int breadth;
Rectangle( int l, int b )
{
length = l;
breadth = b;
}
int printArea()
{
return length * breadth;
}
};

int main()
{
Rectangle rt1( 7, 4 );
Rectangle rt2( 4, 5 );
cout << "Area of first rectangle " << rt1.printArea() << endl;
cout << "Area of second rectangle " << rt2.printArea() << endl;
return 0;
}

You might also like