#include <iostream>
using namespace std;
class rectangle
{
private:
int length;
int width;
int area;
int perimeter;
public:
rectangle(float l,
float w): length(l),width(w)
{ }
void set_data()
{
cout<<
"Enter length_";
cin>>length;
cout<<"enter width_";
cin>>width;
}
void getdata()
{
cout<<"\nlength_"<<length;
cout<<"\nwidth_"<<width;
}
void area()
{
area=length*width;
cout<<"\n area"<<area<<endl;
}
void perimeter()
{
perimeter=length+width;
perimeter=
2*perimeter;
cout<<"\nperimeter"<<perimeter;
}
};
int main()
{
rectangle d1(1,1);
rectangle object;
object.set_data();
object.area();
object.perimeter();
return 0;
}
No comments:
Post a Comment