TConv-0.1 - tconv_utils.cpp
Cerca
 











tconv_utils.cpp

Caricato da: Nihal
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. }
 

Creative Commons License
Il layout di questo sito è concesso sotto licenza Creative Commons.
Per maggiori informazioni sulle licenze dei contenuti del sito, clicca.