-
Notifications
You must be signed in to change notification settings - Fork 0
/
TemperatureConversion.c
112 lines (100 loc) · 2.3 KB
/
TemperatureConversion.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include<stdio.h>
float ctof(float x);
float ftoc(float x);
float ctok(float x);
float ktoc(float x);
float ftok(float x);
float ktof(float x);
float d;
int main()
{
int x;
float v;
printf("To convert celcius to fahrenheit\0331\n");
printf("To convert fahrenheit to celcius\0332\n");
printf("To convert celcius to kelvin\0333\n");
printf("To convert kelvin to celsius\0334\n");
printf("To convert kelvin to fahrenheit\0335\n");
printf("To convert fahrenheit to degrees\0336\n");
printf("Enter respective number required conversion : ");
scanf("%d",&x );
switch(x) {
case 1:
printf("Enter your temperature in celcius: ");
scanf("%f",&v);
d=ctof(v);
printf("%f celcius in fahrenheit is %f\n\n\n\n",v,d);
break;
case 2:
printf("Enter your temperature in farenheit: ");
scanf("%f",&v);
d=ftoc(v);
printf("%f fahrenheit in celcius is %f\n\n\n\n",v,d);
break;
case 3:
printf("Enter your temperature in celcius: ");
scanf("%f",&v);
d=ctok(v);
printf("%f celcius in kelvin is %f\n\n\n\n",v,d);
break;
case 4:
printf("Enter your temperature in kelvin: ");
scanf("%f",&v);
d=ktoc(v);
printf("%f kelvin in celciusis %f\n\n\n\n",v,d);
break;
case 5:
printf("Enter your temperature in kelvin: ");
scanf("%f",&v);
d=ktof(v);
printf("%f kelvin in fahrenheit is %f\n\n\n\n",v,d);
break;
case 6:
printf("Enter your temperature in farenheit: ");
scanf("%f",&v);
d=ftok(v);
printf("%f fahrenheit in kelvin is %f\n\n\n\n",v,d);
break;
default:
printf("enter valid number");
main();
break;
}
return 0;
}
float ctof(float x)
{
float d;
d=(x*1.8)+32;
return d;
}
float ftoc(float x)
{
float d;
d=(x-32)/1.8;
return d;
}
float ctok(float x)
{
float d;
d=x+273.15;
return d;
}
float ktoc(float x)
{
float d;
d=x-273.15;
return d;
}
float ktof(float x)
{
float d;
d=(x-273.15)*1.8+32;
return d;
}
float ftok(float x)
{
float d;
d=(x-32)/1.8+273.15;
return d;
}