Skip to content

Commit 20c1e3c

Browse files
Create AreaOfAnyShape.c
1 parent 85d725c commit 20c1e3c

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

AreaOfAnyShape.c

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#include<stdio.h>
2+
#include<math.h>
3+
4+
int sqr()
5+
{
6+
float s, area;
7+
printf("Enter the side of the square : ");
8+
scanf("%f", &s);
9+
area= s*s;
10+
printf("Area of square = %f",area);
11+
return(area);
12+
}
13+
14+
int rct()
15+
{
16+
float l,b,area;
17+
printf("Enter the length & breadth of rectangle :\n");
18+
scanf("%f %f", &l, &b);
19+
area= l*b;
20+
printf("Area of rectangle = %f",area);
21+
return(area);
22+
}
23+
24+
int trg()
25+
{
26+
float a, b, c, s, area;
27+
printf("Enter the length of three sides of triangle :\n");
28+
scanf("%f %f %f", &a, &b, &c);
29+
s=(a+b+c)/2;
30+
area= sqrt(s*(s-a)*(s-b)*(s-c));
31+
printf("Area of triangle = %f", area);
32+
return(area);
33+
}
34+
35+
int cir()
36+
{
37+
float r, area, pi=3.14;
38+
printf("Enter the radius of circle : ");
39+
scanf("%f",&r);
40+
area= pi*r*r;
41+
printf("Area of circle = %f",area);
42+
return(area);
43+
}
44+
int main()
45+
{
46+
int choice;
47+
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 ");
48+
scanf("%d", &choice);
49+
switch(choice)
50+
{
51+
case 1 :
52+
sqr();
53+
break;
54+
55+
case 2 :
56+
rct();
57+
break;
58+
59+
case 3 :
60+
trg();
61+
break;
62+
63+
case 4 :
64+
cir();
65+
break;
66+
67+
default:
68+
printf("INVALID CHOICE!!");
69+
70+
}
71+
return 0;
72+
73+
}

0 commit comments

Comments
 (0)