-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDikdortgen-Alan.cpp
More file actions
41 lines (39 loc) · 815 Bytes
/
Dikdortgen-Alan.cpp
File metadata and controls
41 lines (39 loc) · 815 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
/* This program calculates the area of a rectangle and dispalys it. */
#include<iostream>
using namespace std;
class Area
{
private:
int length, breadth;
public:
Area() : length(5), breadth(2) { } /* Constructor */
void GetLength()
{
cout << "Enter length and breadth respectively: ";
cin >> length;
cout << "Enter length and breadth respectively: ";
cin >> breadth;
}
int AreaCalculation()
{
return (length*breadth);
}
void DisplayArea(int temp)
{
cout << "Area: " << temp << endl;
}
};
int main()
{
Area A1, A2;
int temp;
A1.GetLength();
temp = A1.AreaCalculation();
A1.DisplayArea(temp);
cout << endl << "Default Area when value is not taken from user" << endl;
// A2.GetLength();
temp = A2.AreaCalculation();
A2.DisplayArea(temp);
system("PAUSE");
return 0;
}