-
Notifications
You must be signed in to change notification settings - Fork 0
/
functionoverloading.cpp
48 lines (41 loc) · 1.08 KB
/
functionoverloading.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
48
#include <iostream>
using namespace std;
// total surface area of cube
int area (int l = 10)
{
return 6*l*l;
}
// area of circle
const float PI = 3.14;
float area (float r)
{
return PI*r*r;
}
// area of rectangle
float area (float l, float b)
{
return l*b;
}
int main (void)
{
// for cube
int cubeLength, cubeArea;
cout << "enter the length of the cube: ";
cin >> cubeLength;
cubeArea = area(cubeLength);
cout << "the area of cube is: " << cubeArea <<endl;
// for circle
float circleRadius, circleArea;
cout << "enter the radius of the circle: ";
cin >> circleRadius;
circleArea = area(circleRadius);
cout << "the area of circle is: " << circleArea <<endl;
// for rectangle
float rectangleLength, rectangleBreadth, rectangleArea;
cout << "enter the length of the rectangle: ";
cin >> rectangleLength;
cout << "enter the breadth of the rectangle: ";
cin >> rectangleBreadth;
rectangleArea = area(rectangleLength, rectangleBreadth);
cout << "the area of rectangle is: " << rectangleArea <<endl;
}