fork download
  1. //Kevin Thomas CS1A Chapter 3, P. 144, #10
  2. /**************************************************************
  3. *
  4. * Convert Celsius to Fahrenheit
  5. * ____________________________________________________________
  6. * This program will convert a given celsius temperature to its fahrenheit equivalent.
  7. *
  8. * Computation is based on the formula:
  9. * F = 9/5 * C + 32
  10. * ____________________________________________________________
  11. * INPUT
  12. *celsius: A float holding the celsius value that should be converted.
  13. *
  14. *
  15. *
  16. *
  17. * OUTPUT
  18. * result: The resulting fahrenheit equivalent of the provided celsius value.
  19. *
  20. **************************************************************/
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main() {
  25. //Declare variables
  26. float celsius;
  27. float result;
  28.  
  29. //Ask for the temperature in celsius
  30. cout << "What is the temperature in celsius: " << endl;
  31. cin >> celsius;
  32.  
  33. //Compute the conversion and store it in the result variable.
  34. result = (celsius * 9 / 5) + 32;
  35. //Output the final value.
  36. cout << celsius << " degrees celsius is equal to " << result << " degrees fahrehheit." << endl;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5300KB
stdin
59
stdout
What is the temperature in celsius: 
59 degrees celsius is equal to 138.2 degrees fahrehheit.