forked from sat5297/hacktober-coding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharea_poly.cpp
More file actions
89 lines (81 loc) · 1.44 KB
/
area_poly.cpp
File metadata and controls
89 lines (81 loc) · 1.44 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//Area of geometric figures uding function overloading
#include<iostream>
#include<cstdlib>
using namespace std;
//Area of a circle
float area(double r)
{
float area = 3.14*r*r;
cout<<"The area of the circle is: "<<area<<"\n";
}
//Area of rectangle
float area(float l, float b)
{
float area = (l*b);
cout<<"The area of the rectangle is: "<<area<<"\n";
}
//Area of triangle
float area(double b, double h)
{
float area = (0.5*b*h);
cout<<"The area of the triangle is: "<<area<<"\n";
}
//Area of a square
float area(float s)
{
float area = s*s;
cout<<"The area of the square is: "<<area<<"\n";
}
int main()
{
float s, l, b;
double r, base, h;
int ch;
while(1)
{
//The Menu bar
cout<<"\n1. Area of Circle";
cout<<"\n2. Area of Rectangle";
cout<<"\n3. Area of Triangle";
cout<<"\n4. Area of Square";
cout<<"\n5. Exit\n";
cin>>ch;
//Switch case to implement the choices
switch(ch)
{
case 1:
{
cout<<"\nEnter the Radius of circle: ";
cin>>r;
area(r);
break;
}
case 2:
{
cout<<"\nEnter the length and breadth of the rectangle: ";
cin>>l>>b;
area(l,b);
break;
}
case 3:
{
cout<<"\nEnter the base and height of the triangle: ";
cin>>base>>h;
area(base,h);
break;
}
case 4:
{
cout<<"\nEnter the side of the square: ";
cin>>s;
area(s);
break;
}
case 5:
exit(0);
default:
cout<<"Enter a valid choice \n";
}
}
return 0;
}