-
Notifications
You must be signed in to change notification settings - Fork 0
/
measurements.c
70 lines (59 loc) · 1.85 KB
/
measurements.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
#include <stdio.h>
int main()
{
char input;
float kmsToMiles = 0.621371;
float inchesToFoot = 0.0833333;
float cmsToInches = 0.393701;
float poundToKgs = 0.453592;
float inchesToMeters = 0.0254;
float first, second;
while (1)
{
printf("Enter the input character. q to quit\n 1. kms to miles\n 2. inches to foot\n 3. cms to inches\n 4. pound to kgs\n 5. inches to meters\n");
scanf(" %c", &input);
// printf("The character is '%c'", input);
switch (input)
{
case 'q':
printf("Quitting the program...");
goto end;
break;
case '1':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * kmsToMiles;
printf("%.2f Kms is equal to %.2f Miles\n\n\n", first, second);
break;
case '2':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * inchesToFoot;
printf("%f Inches is equal to %f Foot\n", first, second);
break;
case '3':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * cmsToInches;
printf("%f Cms is equal to %f Inches\n", first, second);
break;
case '4':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * poundToKgs;
printf("%f Pounds is equal to Kgs %f \n", first, second);
break;
case '5':
printf("Enter quantity in terms of first unit\n");
scanf("%f", &first);
second = first * inchesToMeters;
printf("%f inches is equal to %f meters \n", first, second);
break;
default:
printf("In default now");
break;
}
}
end:
return 0;
}