#include <iostream>
using namespace std;
class Rectangle
{
public :
int length;
int breadth;
Rectangle(int l, int b)
{
length = l;
breadth = b;
}
int area()
{
return length*breadth;
}
int perimeter()
{
int p = 2*(length*breadth);
return p;
}
};
int main()
{
int l,b;
cout << "Enter length and breadth : ";
cin >> l >> b;
Rectangle r(l,b);
int a = r.area();
cout <<"Area is : "<<a << endl;
int peri = r.perimeter();
cout <<"perimeter is :"<<peri;
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter