fork download
  1. // Torrez, Elaine CS1A Chapter 3 P. 144, #10
  2.  
  3. /******************************************************************************************
  4.  *
  5.  * CONVERT CELSIUS TO FAHRENHEIT
  6.  *
  7.  * --------------------------------------------------------------------------------
  8.  * This program converts a temperature in Celsius to its equivalent temperature
  9.  * in Fahrenheit using the standard conversion formula.
  10.  * --------------------------------------------------------------------------------
  11.  *
  12.  * INPUT
  13.  * celsius : Temperature in Celsius
  14.  *
  15.  * OUTPUT
  16.  * fahrenheit : Temperature in Fahrenheit
  17.  *
  18.  *******************************************************************************************/
  19.  
  20. #include <iostream>
  21. #include <iomanip> // Included for fixed and setprecision
  22. using namespace std;
  23.  
  24. int main ()
  25. {
  26. double celsius; // INPUT Temperature in Celsius
  27. double fahrenheit; // OUTPUT Temperature in Fahrenheit
  28.  
  29. cout << "Enter the temperature in Celsius: ";
  30. cin >> celsius; // Get Celsius value from user
  31.  
  32. fahrenheit = (9.0 / 5.0) * celsius + 32; // Convert Celsius to Fahrenheit
  33.  
  34. cout << fixed << setprecision(1); // Format output with one decimal place
  35. cout << "\nTemperature in Fahrenheit: " << fahrenheit << endl;
  36.  
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Enter the temperature in Celsius: 
Temperature in Fahrenheit: 212.0