-
Notifications
You must be signed in to change notification settings - Fork 369
/
AreaOfAnyShape.c
73 lines (63 loc) · 1.5 KB
/
AreaOfAnyShape.c
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
#include<stdio.h>
#include<math.h>
int sqr()
{
float s, area;
printf("Enter the side of the square : ");
scanf("%f", &s);
area= s*s;
printf("Area of square = %f",area);
return(area);
}
int rct()
{
float l,b,area;
printf("Enter the length & breadth of rectangle :\n");
scanf("%f %f", &l, &b);
area= l*b;
printf("Area of rectangle = %f",area);
return(area);
}
int trg()
{
float a, b, c, s, area;
printf("Enter the length of three sides of triangle :\n");
scanf("%f %f %f", &a, &b, &c);
s=(a+b+c)/2;
area= sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of triangle = %f", area);
return(area);
}
int cir()
{
float r, area, pi=3.14;
printf("Enter the radius of circle : ");
scanf("%f",&r);
area= pi*r*r;
printf("Area of circle = %f",area);
return(area);
}
int main()
{
int choice;
printf("Enter 1 if you want to calculate are of square\nEnter 2 if you want to calculate are of rectangle\nEnter 3 if you want to calculate are of triangle\nEnter 4 if you want to calculate are of circle\n ");
scanf("%d", &choice);
switch(choice)
{
case 1 :
sqr();
break;
case 2 :
rct();
break;
case 3 :
trg();
break;
case 4 :
cir();
break;
default:
printf("INVALID CHOICE!!");
}
return 0;
}