-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASSI21.CPP
47 lines (37 loc) · 1.08 KB
/
ASSI21.CPP
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
44
45
46
47
// creating a class rectangle in creating it's object and calling member functions
#include<iostream.h>
#include<conio.h>
class rectangle{
private: float width, height, area, perimeter;
public: void getInput(){
cout<<"Enter Width of Rectangle : ";
cin>>width;
cout<<"Enter Height of Rectangle : ";
cin>>height;
calc();
}
void calc(){
area= height*width;
perimeter= (height+width)*2;
}
float getArea(){
return area;
}
float getPerimeter(){
return perimeter;
}
};
void main(){
clrscr();
rectangle rect1, rect2;
cout<<"Enter info About First Rectangle : "<<endl;
rect1.getInput();
cout<<"Enter Info About Second Rectangle : "<<endl;
rect2.getInput();
cout<<"\n\n"<<endl;
cout<<"Area of First Rectangle : "<< rect1.getArea()<<endl;
cout<<"Area of Second Rectangle : "<< rect2.getArea()<<endl;
cout<<"Perimeter of First Rectangle : "<< rect1.getPerimeter()<<endl;
cout<<"Perimeter of Second Rectangle : "<< rect2.getPerimeter()<<endl;
getch();
}