-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMYFUNC.C
62 lines (58 loc) · 1.16 KB
/
MYFUNC.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
#include<stdio.h>
#include<conio.h>
void circle() {
float radius;
printf("Enter radius: ");
scanf("%f", &radius );
printf("The area of the circle is : %.2f", ((22/(float)7)*radius*radius));
getch();
}
void rectangle() {
float length,breadth;
printf("Enter length: ");
scanf("%f", &length );
printf("Enter breadth: ");
scanf("%f", &breadth );
printf("The area of the rectangle is : %.2f", (length*breadth));
getch();
}
void triangle() {
float base,height;
printf("Enter base: ");
scanf("%f", &base );
printf("Enter height: ");
scanf("%f", &height );
printf("The area of the triangle is : %.2f", (0.5*base*height));
getch();
}
void square() {
float side;
printf("Enter side: ");
scanf("%f", &side );
printf("The area of the square is : %.2f", (side*side));
getch();
}
void main() {
int selected_optn;
clrscr();
printf("Menu: \n 1.Circle \n 2.Rectangle \n 3.Triangle \n 4.Square \nEnter desired option:");
scanf("%d", &selected_optn);
switch(selected_optn) {
case 1:
circle();
break;
case 2:
rectangle();
break;
case 3:
triangle();
break;
case 4:
square();
break;
default:
printf("You entered a wrong option");
getch();
main();
}
}