-
Notifications
You must be signed in to change notification settings - Fork 0
/
temperatura.c
66 lines (58 loc) · 1.51 KB
/
temperatura.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
#include <stdio.h>
float celsiusFaren (char tempC, float temp) {
temp = (tempC * 9)/5 + 32;
return temp;
}
float celsiusKel (char tempC, float temp){
temp = tempC - 273.15;
return temp;
}
float farenheintCel (char tempF, float temp){
temp = ((tempF - 32)*5)/9;
return temp;
}
float farenheintKel (char tempF, float temp){
temp = 273.15 + (tempF - 32)*5/9;
return temp;
}
float kelvinFaren (char tempK, float temp){
temp = 1.8*(tempK -273.15) + 32;
return temp;
}
float kelvinCel(char tempK, float temp){
temp = tempK + 273.15;
return temp;
}
int main(){
char a;
char b;
float temp;
printf("-----------------------Informe os dados com letra maiúscula!!! ---------------------\n");
scanf(" %c\n", &a);
scanf(" %c\n", &b);
if (a == 'C' && b == 'F'){
celsiusFaren(a, temp);
printf("%f", celsiusFaren(a, temp));
}
if (a == 'C' && b == 'K'){
celsiusKel(a, temp);
printf("%f", celsiusKel(a, temp));
}
if (a == 'F' && b == 'C'){
farenheintCel(a, temp);
printf("%f", farenheintCel(a, temp));
}
if (a == 'F' && b == 'K'){
farenheintKel(a, temp);
printf("%f", farenheintKel(a, temp));
}
if (a == 'K' && b == 'F'){
kelvinFaren(a, temp);
printf("%f", kelvinFaren(a, temp));
}
if (a == 'K' && b == 'C'){
kelvinCel(a, temp);
printf("%f", kelvinCel(a, temp));
}
return 0;
}