-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunitsnconversion.c
72 lines (57 loc) · 1.61 KB
/
unitsnconversion.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
/*
kms to miles
inches to foot
cms to foot
pounds to kgs
inches to meters
*/
#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("\n1. Kms to Miles\n2. Inches to Foot\n3. Cms to Foot\n4. Pounds to Kgs\n5. Inches to Meters\n");
printf("Enter the input characters(q to quit): ");
scanf(" %c", &input);
printf("\nEnter quantity in term of first unit: ");
scanf("%f", &first);
switch (input)
{
case 'q':
printf("Quitting the program......");
goto end;
break;
case '1':
second = first * kmsToMiles;
printf("%f Kms is equals to Miles %f \n", first, second);
break;
case '2':
second = first * inchesToFoot;
printf("%f Inches is equals to %f Foot\n", first, second);
break;
case '3':
second = first * cmsToInches;
printf("%f Cms is equals to %f Inches\n", first, second);
break;
case '4':
second = first * poundToKgs;
printf("%f Pounds is equals to %f Kgs \n", first, second);
break;
case '5':
second = first * inchesToMeters;
printf("%f Inches is equals to %f Meters\n", first, second);
break;
default:
break;
}
}
end:
return 0;
}