-
Notifications
You must be signed in to change notification settings - Fork 771
/
Conversion_program
56 lines (49 loc) · 1.71 KB
/
Conversion_program
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
#include<stdio.h>
int main() {
float unit, result;
char input;
float kmsToMiles = 0.621371;
float inchesToFoot = 0.0833333;
float cmsToInches = 0.393701;
float poundToKgs = 0.453592;
float inchesToMeters = 0.0254;
while (1 != 0) {
printf("Please choose an option \n 1.kmsToMiles\n 2.inchesToFoot\n 3.cmsToInches\n 4.poundToKgs\n q.Quit the program\n");
printf("Enter a input \n");
scanf("%c", &input);
switch (input) {
case '1':
printf("enter the unit to be converted \n");
scanf("%f", &unit);
result = unit * kmsToMiles;
printf("%f kms is converted to %f miles \n", unit, result);
break;
case '2':
printf("enter the unit to be converted \n");
scanf("%f", &unit);
result = unit * inchesToFoot;
printf("%f is converted to %f \n", unit, result);
break;
case '3':
printf("enter the unit to be converted \n");
scanf("%f", &unit);
result = unit * cmsToInches;
printf("%f is converted to %f \n", unit, result);
break;
case '4':
printf("enter the unit to be converted \n");
scanf("%f", &unit);
result = unit * poundToKgs;
printf("%f is converted to %f \n", unit, result);
break;
case 'q':
printf("Quiting the program \n");
goto end;
break;
default:
printf("In default now \n");
}
}
end:
return 0;
}