-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample2.c
37 lines (33 loc) · 1.02 KB
/
example2.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
#include <stdio.h>
#include <ctype.h> // for tolower() function
int main(){
char choice;
const float pi = 3.14;
float radius,side, base,h;
printf("-----------MENU-----------\n"
"- 'C' or 'c' Circle -\n"
"- 'T' or 't' triangle -\n"
"- 'S' or 's' square -\n"
"--------------------------\n");
printf("Your choice : ");
scanf("%c",&choice);
switch (tolower(choice)) {
case 'c':
printf("Enter the radius: ");
scanf("%f",&radius);
printf("Area: %.2f",pi*radius*radius);
break;
case 't' :
printf("Enter the base: ");
scanf("%f",&base);
printf("Enter the height: ");
scanf("%f",&h);
printf("Area: %.2f",base*h/2);
break;
case 's':
printf("Enter the side: ");
scanf("%f",&side);
printf("Area: %.2f",side*side);
break;
}
}