fork download
  1. //Xinnuo Wang CS1A Chapter6 Page.370 #7
  2. /*******************************************************************************
  3.  *
  4.  * Covert temperature
  5.  * _____________________________________________________________________________
  6.  * The program displays a table of the Fahrenheit temperatures 0 through 20 and
  7.  * their Celsius equivalents.
  8.  *
  9.  * This program is based on the function:
  10.  * C = 5/9 * ( F - 32)
  11.  * _____________________________________________________________________________
  12.  * Input
  13.  * F : Fahrenheit temperature
  14.  * Output
  15.  * C : Celsius temperature
  16.  *
  17.  * ****************************************************************************/
  18. #include <iostream>
  19. using namespace std;
  20. double celsius (int);
  21. int main()
  22. {
  23. int F;
  24. for ( F = 0; F < 20; F++)
  25. {
  26. cout << "The Celsius temperature is: " << celsius(F) << endl;
  27.  
  28. }
  29. return 0;
  30. }
  31. double celsius (int F)
  32. {
  33. double C;
  34. C = 5.0/9 * ( F - 32);
  35. return (C);
  36. }
  37.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
The Celsius temperature is: -17.7778
The Celsius temperature is: -17.2222
The Celsius temperature is: -16.6667
The Celsius temperature is: -16.1111
The Celsius temperature is: -15.5556
The Celsius temperature is: -15
The Celsius temperature is: -14.4444
The Celsius temperature is: -13.8889
The Celsius temperature is: -13.3333
The Celsius temperature is: -12.7778
The Celsius temperature is: -12.2222
The Celsius temperature is: -11.6667
The Celsius temperature is: -11.1111
The Celsius temperature is: -10.5556
The Celsius temperature is: -10
The Celsius temperature is: -9.44444
The Celsius temperature is: -8.88889
The Celsius temperature is: -8.33333
The Celsius temperature is: -7.77778
The Celsius temperature is: -7.22222