Untitled

mail@pastecode.io avatar
unknown
plain_text
16 days ago
501 B
2
Indexable
Never
#include<iostream>
using namespace std;
class rectangle
{
private:
int length, breadth;

public:
void set data(int l, int b)
{
length=l;
breadth=b;

}
void showdata(){
cout<<"Length="<<length<<endl
<<"Breadth="<<breadth<<endl;

}
int findarea()
{
return length*breadth;
}
int findperimeter(){
return(2*length+breadth);
}

};
int main(){
rectangle r;
r.setdata(4,2);
r.showdata();
cout<<"Area="<<r.findarea()<<endl;
cout<<"Perimeter="<<r.findperimeter();
return 0
}
Leave a Comment