forked from rituburman/hacktoberfest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAreaofpolygons.cpp
More file actions
61 lines (61 loc) · 1.29 KB
/
Areaofpolygons.cpp
File metadata and controls
61 lines (61 loc) · 1.29 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
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
//Area of rectangle
void area(int l,int b)
{
int area=l*b;
cout<<area;
}
//Area of triangle
void area(int base,float h)
{
int area;
area=(0.5*base*h);
cout<<area;
}
//Area of circle
void area(float r)
{
int area;
area=(3.14*r*r);
cout<<area;
}
//Area of square
void area(int s)
{
int area;
area=s*s;
cout<<area;
}
void main()
{
clrscr;
int choice;
cout<<"Enter 1 for displaying area of rectangle, 2 for area of triangle, 3 for area of circle and 4 for area of square";
cin>>choice;
switch(choice)
{
case 1: int l,b;
cout<<"enter the length and breadth of rectangle";
cin>>l>>b;
area(l,b);
break;
case 2: int b,float h;
cout<<"enter the base and height of triangle";
cin>>b>>h;
area(b,h);
break;
case 3: float r;
cout<<"enter the radius of the circle";
cin>>r;
area(r);
break;
case 4: int s;
cout<<"enter the side of the square";
cin>>s;
area(s);
break;
default: cout<< "Option entered is wrong.";
getch();
}