Source Code

#include<iostream>
using namespace std;
#include<iomanip>
class rectangle
{
float length;
float breadth;
public:
void setdata (int l, int b)
{
length=l;
breadth=b;
}
void showdata()
{
cout<<"length="<<length<<endl;
cout<<"Breadth="<<breadth<<endl;
}
float area()
{
return length*breadth;
}
void getdata()
{
cout<<"Enter length:\n";
cin>>length;
cout<<"Enter breadth:\n";
cin>>breadth;
setdata(length,breadth);
}
};
int main()
{
rectangle r;
r.getdata();
r.showdata();
cout<<"Area="<<r.area();
}

OUTPUT


Enter length:
25
Enter breadth:
5
length=25
Breadth=5
Area=125

Share To:

Arogya Thapa Magar

Post A Comment:

0 comments so far,add yours