-
Notifications
You must be signed in to change notification settings - Fork 1
/
unit_convertor.c
87 lines (75 loc) · 1.75 KB
/
unit_convertor.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <stdio.h>
int km_to_miles()
{
float km;
printf("Enter the distance in km:\n");
scanf("%f", &km);
printf("The converted distance is %.2f miles", km * 0.62);
}
int inches_to_foot()
{
float inches;
printf("Enter the length in inches:\n");
scanf("%f", &inches);
printf("The converted length is %.2f feet.", inches / 12);
}
int cms_to_inches()
{
float cms;
printf("Enter the length in cms:\n");
scanf("%f", &cms);
printf("The converted length is %.2f inches.", cms / 2.54);
}
int pounds_to_kgs()
{
float pounds;
printf("Enter the weight in pounds:\n");
scanf("%f", £s);
printf("The converted weight is %.2f kgs.", pounds / 2.205);
}
int inches_to_mtr()
{
float inches;
printf("Enter the length in inches:\n");
scanf("%f", &inches);
printf("The converted length is %.2f meters.", inches / 39.37);
}
int main()
{
new : while (1)
{
int i;
printf("\n\n\n|||||| This is a Unit Conertor Program ||||||\n\nEnter 1 for kms to miles conversion.\nEnter 2 for inches to feet conversion.\nEnter 3 for cms to inches conversion.\nEnter 4 for pounds to kgs conversion.\nEnter 5 for inches to meters conversion.\nENTER HERE:: ");
scanf("%d", &i);
if (i > 5)
{
printf("Pls Choose from the above options only");
goto new;
}
else if (i < 1)
{
printf("Pls Choose from the above options only");
goto new;
}
switch (i)
{
case 1:
km_to_miles();
break;
case 2:
inches_to_foot();
break;
case 3:
cms_to_inches();
break;
case 4:
pounds_to_kgs();
break;
default:
inches_to_mtr();
break;
}
}
end:
return 0;
}