-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAREA.C
90 lines (76 loc) · 2 KB
/
AREA.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*********************************************************************************
Statement - Find the ares of different geometrical figures such as circle, square, rectangle
Programmer - Vineet Choudhary
Written For - https://developerinsider.co
*********************************************************************************/
#include <stdio.h>
#include <conio.h>
void main()
{
int fig_code;
float side,base,length,bredth,height,area,radius;
clrscr();
printf("-------------------------\n");
printf(" 1 --> Circle\n");
printf(" 2 --> Rectangle\n");
printf(" 3 --> Triangle\n");
printf(" 4 --> Square\n");
printf("-------------------------\n");
printf("Enter the Figure code\n");
scanf("%d",&fig_code);
switch(fig_code)
{
case 1: printf("Enter the radius\n");
scanf("%f",&radius);
area=3.142*radius*radius;
printf("Area of a circle=%f\n", area);
break;
case 2: printf("Enter the bredth and length\n");
scanf("%f %f",&bredth, &length);
area=bredth *length;
printf("Area of a Reactangle=%f\n", area);
break;
case 3: printf("Enter the base and height\n");
scanf("%f %f",&base,&height);
area=0.5 *base*height;
printf("Area of a Triangle=%f\n", area);
break;
case 4: printf("Enter the side\n");
scanf("%f",&side);
area=side * side;
printf("Area of a Square=%f\n", area);
break;
default: printf("Error in figure code\n");
break;
} /* End of switch */
getch();
} /* End of main() */
/*----------------------------------------------------
Output
Run 1
-------------------------
1 --> Circle
2 --> Rectangle
3 --> Triangle
4 --> Square
-------------------------
Enter the Figure code
2
Enter the bredth and length
2
6
Area of a Reactangle=12.000000
Run 2
-------------------------
1 --> Circle
2 --> Rectangle
3 --> Triangle
4 --> Square
-------------------------
Enter the Figure code
3
Enter the base and height
5
7
Area of a Triangle=17.500000
------------------------------------------------------*/