fork download
  1. // Cenyao Huang CS1A Chapter 3, P. 144, #10
  2. /************************************************************************
  3. * CONVERT CELSIUS TO FAHRENHEIT
  4. * This program converts celsius to fahrenheit temperatures.
  5. *
  6. * This program will use the formula:
  7. * F = 9.0/5.0 * C + 32
  8. *
  9. * Input
  10. * F : the temperature in fahrenheit
  11. * C : the temperature in celsius
  12. *
  13. * Output :
  14. * F : the temperature in fahrenheit
  15. *
  16. ************************************************************************/
  17.  
  18. #include <iostream>
  19. #include <string>
  20. using namespace std;
  21.  
  22. int main() {
  23. double C, F; // assign data type and value to variable
  24.  
  25. cout << "Please enter the temperature in celsius: "; // get temperature needed to convert
  26. cin >> C;
  27. cout << C << "°C" << endl;
  28.  
  29. F = 9.0/5.0 * C + 32; //calculate and display converted temperature
  30. cout << "Temperature in fahrenheit: " << F << "°F";
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5280KB
stdin
40
stdout
Please enter the temperature in celsius: 40°C
Temperature in fahrenheit: 104°F