fork download
  1. //Cameron Pham CS1A Chapter 3, P. 144, #10
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * Convert Celsius to Fahrenheit
  6.  * _____________________________________________________________________________
  7.  *
  8.  * This program converts a temperature from Celsius to Fahrenheit.
  9.  *
  10.  * Computation is based on the formula:
  11.  * F = (9 / 5) * C + 32
  12.  * _____________________________________________________________________________
  13.  *
  14.  * INPUT
  15.  * celsius: Temperature in degrees Celsius
  16.  *
  17.  * OUTPUT
  18.  * fahrenheit: Equivalent temperature in degrees Fahrenheit
  19.  *
  20.  ******************************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26. // Declare variables to store the Celsius and Fahrenheit temperatures.
  27. double celsius;
  28. double fahrenheit;
  29.  
  30. // Ask the user to enter the temperature in Celsius.
  31. cout << "Enter the temperature in Celsius: ";
  32. cin >> celsius;
  33.  
  34. // Convert Celsius to Fahrenheit using the given formula.
  35. fahrenheit = (9.0 / 5.0) * celsius + 32;
  36.  
  37. // Display the converted temperature.
  38. cout << "The temperature is " << fahrenheit << " degrees Fahrenheit." <<
  39. endl;
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0.01s 5280KB
stdin
20
stdout
Enter the temperature in Celsius: The temperature is 68 degrees Fahrenheit.