class rectangle
{
private:
int len,br;
public:
void getdata( )
{
cout<
cin>>len>>br;
}
void setdata(int l,int b)
{
len=l;
br=b;
}
void displaydata()
{
cout<
cout<
}
void area_peri()
{
int a,p;
a=len*br;
p=2*(len+br);
cout<
cout<
}
}; //End of Class
void main( )
{
rectangle r1,r2,r3; //define three objects of class rectangle
r1.setdata(10,20); //set data in elements of the object
r1.display( ); //display the data set by setdata()
r1.area_peri( ); //calculate and print area and perimeter
r2.setdata(5,8);
r2.displaydata( );
r2.area_peri( );
r3.getdata( ); //receive data from keyboard
r3.displaydata( );
r3.area_peri( );
}
No comments:
Post a Comment