-
Notifications
You must be signed in to change notification settings - Fork 1
/
grados.c
84 lines (81 loc) · 2.05 KB
/
grados.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
#include <stdio.h>
int MostrarMenu();
float CelsiusAFarenheit();
float CelsiusAKelvin();
float FarenheitAKelvin();
float FarenheitACelsius();
int main()
{
//declarando variables
int opcion=0;
//llamando modulos
MostrarMenu();
scanf("%i", & opcion);
switch(opcion) {
case 1: { CelsiusAFarenheit(); break; }
case 2: { CelsiusAKelvin(); break; }
case 3: { FarenheitAKelvin(); break; }
case 4: { FarenheitACelsius(); break; }
case 5: { printf("FIN \n"); break; }
default:{ printf("Error\n"); }
}
return 0;
}
int MostrarMenu()
{
printf ("Convertidor de temperaturas \n");
printf ("Presiona el numero de la opcion deseada \n");
printf ("1.- Celsius a Farenheit \n");
printf ("2.- Celsius a Kelvin \n");
printf ("3.- Farenheit a Kelvin \n");
printf ("4.- Farenheit a Celsius \n");
return 0;
}
float CelsiusAFarenheit(){
//Declaracion de variables locales
float C;
float F;
printf ("Convertidor de temperaturas \n");
printf ("1.- Celsius a Farenheit \n");
printf ("Introduzca el valor de Celsius \n");
scanf ("%f", &C);
F=(1.8*C)+32;
printf("Los grados en Farenheit son: %f \n", F);
return 0;
}
float CelsiusAKelvin(){
//Declaracion de variables locales
float C;
float K;
printf ("Convertidor de temperaturas \n");
printf ("2.- Celsius a Kelvin \n");
printf ("Introduzca el valor de Celsius \n");
scanf ("%f", &C);
K=C+273.15;
printf("Los grados en Kelvin son: %f \n", K);
return 0;
}
float FarenheitAKelvin(){
//Declaracion de variables locales
float F;
float K;
printf ("Convertidor de temperaturas \n");
printf ("3.- Farenheit a Kelvin \n");
printf ("Introduzca el valor de Farenheit \n");
scanf ("%f", &F);
K=((F-32)*5/9)+273.15;
printf("Los grados en Kelvin son: %f \n", K);
return 0;
}
float FarenheitACelsius(){
//Declaracion de variables locales
float F;
float C;
printf ("Convertidor de temperaturas \n");
printf ("4.- Farenheit a Celsius \n");
printf ("Introduzca el valor de Farenheit \n");
scanf ("%f", &F);
C=(F-32)*5/9;
printf("Los grados en Celsius son: %f \n", C);
return 0;
}