fork(1) download
  1. /******************************************************************************
  2.  * CELSIUS TO FAHRENHEIT TABLE
  3.  *
  4.  * This program displays a conversion table of Celsius to Fahrenheit
  5.  * for temperatures from 0 to 20 degrees Celsius.
  6.  *
  7.  * Formula: F = (9.0 / 5.0) * C + 32
  8.  *
  9.  * OUTPUT:
  10.  * Celsius and Fahrenheit values displayed side by side.
  11.  ******************************************************************************/
  12.  
  13. #include <iostream>
  14. #include <iomanip>
  15. using namespace std;
  16.  
  17. int main() {
  18. cout << "Celsius to Fahrenheit Conversion Table\n";
  19. cout << "--------------------------------------\n";
  20. cout << "Celsius\tFahrenheit\n";
  21. cout << "-------------------\n";
  22.  
  23. // Loop from 0°C to 20°C
  24. for (int celsius = 0; celsius <= 20; celsius++) {
  25. double fahrenheit = (9.0 / 5.0) * celsius + 32;
  26. cout << setw(3) << celsius << "\t"
  27. << fixed << setprecision(1) << fahrenheit << endl;
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Celsius to Fahrenheit Conversion Table
--------------------------------------
Celsius	Fahrenheit
-------------------
  0	32.0
  1	33.8
  2	35.6
  3	37.4
  4	39.2
  5	41.0
  6	42.8
  7	44.6
  8	46.4
  9	48.2
 10	50.0
 11	51.8
 12	53.6
 13	55.4
 14	57.2
 15	59.0
 16	60.8
 17	62.6
 18	64.4
 19	66.2
 20	68.0