Skip to content

Commit 05da8fc

Browse files
authored
Menu_driven_program
A menu-driven program conversion where many cases are there where input is taken from the user and the amount is converted and the result is printed
1 parent c5c05c2 commit 05da8fc

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Conversion_program

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include<stdio.h>
2+
int main() {
3+
4+
float unit, result;
5+
char input;
6+
float kmsToMiles = 0.621371;
7+
float inchesToFoot = 0.0833333;
8+
float cmsToInches = 0.393701;
9+
float poundToKgs = 0.453592;
10+
float inchesToMeters = 0.0254;
11+
12+
while (1 != 0) {
13+
printf("Please choose an option \n 1.kmsToMiles\n 2.inchesToFoot\n 3.cmsToInches\n 4.poundToKgs\n q.Quit the program\n");
14+
printf("Enter a input \n");
15+
scanf("%c", &input);
16+
switch (input) {
17+
case '1':
18+
printf("enter the unit to be converted \n");
19+
scanf("%f", &unit);
20+
result = unit * kmsToMiles;
21+
printf("%f kms is converted to %f miles \n", unit, result);
22+
break;
23+
case '2':
24+
printf("enter the unit to be converted \n");
25+
scanf("%f", &unit);
26+
result = unit * inchesToFoot;
27+
printf("%f is converted to %f \n", unit, result);
28+
break;
29+
30+
case '3':
31+
printf("enter the unit to be converted \n");
32+
scanf("%f", &unit);
33+
result = unit * cmsToInches;
34+
printf("%f is converted to %f \n", unit, result);
35+
break;
36+
37+
38+
case '4':
39+
printf("enter the unit to be converted \n");
40+
scanf("%f", &unit);
41+
result = unit * poundToKgs;
42+
printf("%f is converted to %f \n", unit, result);
43+
break;
44+
case 'q':
45+
printf("Quiting the program \n");
46+
goto end;
47+
break;
48+
default:
49+
printf("In default now \n");
50+
}
51+
52+
}
53+
end:
54+
55+
return 0;
56+
}

0 commit comments

Comments
 (0)