Advertisement
janac

Convert Fahrenheit to Celsius

Nov 24th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // Convert Fahrenheit to Celsius.
  5. int main()
  6. {
  7.     double F = 0; // temperature in Fahrenheit.
  8.     double C = 0; // temperature in Celsius.
  9.  
  10.     cout << "Enter degrees Fahrenheit:\n";
  11.     cin >> F; // Get the degrees Fahrenheit.
  12.     C = (5.0 / 9.0) * (F - 32); // Convert.
  13.  
  14.     // Display the result
  15.     cout << F << " degrees Fahrenheit is "
  16.         << C << " degrees Celsius.\n";
  17.  
  18.     // End the program.
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement