#include<iostream>
using namespace std;
class rectangle
{
public:
int length;
int breadth;
int area()
{
return length*breadth;
}
int perimeter()
{
return 2*(length+breadth);
}
int sum()
{
return length+breadth;
}
int rec()
{
return 4*(length+breadth);
}
};
int main()
{
rectangle r1,r2;
r1.length=10;
r1.breadth=20;
cout<<"The area r1 is :"<<r1.area()<<endl;
cout<<"The perimeter of r1 is :"<<r1.perimeter()<<endl;
cout<<"The sum r1 is : "<<r1.sum()<<endl;
cout<<"The rec r1 is : "<<r1.rec()<<endl;
r2.length=20;
r2.breadth=30;
cout<<"The area of r2 is :"<<r2.area()<<endl;
cout<<"The perimeter of r2 is :"<<r2.perimeter()<<endl;
cout<<"The sum r2 is : "<<r2.sum()<<endl;
cout<<"The rec r2 is : "<<r2.rec()<<endl;
}
No comments:
Post a Comment