fork download
  1. //Ryan Shahriyarpour CS1A Carl Argila CH5 HW Q:5
  2. //
  3. /*****************************************************************************
  4.  *
  5.  * Celsius to Fahrenheit Table
  6.  *
  7.  *********************
  8.  *
  9.  * This program displays a table of Celsius temperatures from 0 to 20 and
  10.  * their Fahrenheit equivalents. The conversion formula is:
  11.  * F = (C * 9/5) + 32
  12.  *
  13.  * INPUT
  14.  * None (fixed values used)
  15.  *
  16.  * OUTPUT
  17.  * Table showing Celsius temperatures and their Fahrenheit equivalents
  18.  *
  19.  ****************************************************************************/
  20.  
  21. #include <iostream>
  22. #include <iomanip>
  23. using namespace std;
  24.  
  25. int main()
  26. {
  27. cout << "Celsius\t\tFahrenheit\n";
  28. cout << "---------------------------------------\n";
  29.  
  30. // Display temperatures from 0 to 20 Celsius
  31. for (int celsius = 0; celsius <= 20; celsius++)
  32. {
  33. double fahrenheit = (celsius * 9.0 / 5.0) + 32.0;
  34. cout << celsius << "\t\t" << fixed << setprecision(1) << fahrenheit << endl;
  35. }
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
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