-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice5.cpp
More file actions
43 lines (38 loc) · 749 Bytes
/
Copy pathpractice5.cpp
File metadata and controls
43 lines (38 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//define a rectangle class
#include <iostream>
using namespace std;
class Rect
{
private:
int length,breadth;
public:
void setDimension(float l,float b)
{
length = l; breadth = b;
}
void showDimension()
{
cout<<"Length is "<<length<<" Breadth is "<<breadth<<endl;
}
float getArea()
{
return(length*breadth);
}
float getPerimeter()
{
return(2*(length+breadth));
}
};
int main()
{
float a,b;
system("cls");
Rect r1;
cout<<"Enter length and breadth of Rectangle ";
cin>>a>>b;
r1.setDimension(a,b);
r1.showDimension();
cout<<"Area is "<<r1.getArea()<<endl;
cout<<"Perimeter is "<<r1.getPerimeter()<<endl;
system("pause");
}