Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
TConv-0.1 - tconv_utils.cpp

tconv_utils.cpp

Caricato da:
Scarica il programma completo

  1. #include "tconv_utils.h"
  2.  
  3. /* Here we implement functions for converting from a unit to another... It's really boring : */
  4.  
  5. double C2F(double celsius)
  6. {
  7.     double fahrenheit = (celsius + 32) * 9 / 5;
  8.     return fahrenheit;
  9. }
  10.  
  11. double C2K(double celsius)
  12. {
  13.     double kelvin = celsius + 273.15;
  14.     return kelvin;
  15. }
  16.  
  17. double F2C(double fahrenheit)
  18. {
  19.     double celsius = (fahrenheit - 32) * 5 / 9;
  20.     return celsius;
  21. }
  22.  
  23. double F2K(double fahrenheit)
  24. {
  25.     double kelvin = C2K(F2C(fahrenheit));
  26.     return kelvin;
  27. }
  28.  
  29. double K2C(double kelvin)
  30. {
  31.     double celsius = kelvin - 273.15;
  32.     return celsius;
  33. }
  34.  
  35. double K2F(double kelvin)
  36. {
  37.     double fahrenheit = C2F(K2C(kelvin));
  38.     return fahrenheit;
  39. }