C++ Fahrenheit to Celsius
To convert Fahrenheit to Celsius in C++, you can use the following code:
#include <iostream>
using namespace std;
int main() {
double fahrenheit, celsius;
cout << "Enter the temperature in Fahrenheit: ";
cin >> fahrenheit;
celsius = (fahrenheit - 32) * 5/9;
cout << "The temperature in Celsius is: " << celsius << "°C" << endl;
return 0;
}
Explanation: - Include the necessary header files for input/output operations. - Define the main function as the entry point of the program. - Declare variables for storing the Fahrenheit and Celsius temperatures. - Prompt the user to enter the temperature in Fahrenheit. - Read the input Fahrenheit temperature from the user. - Apply the formula to convert Fahrenheit to Celsius: (Fahrenheit - 32) * 5/9. - Display the result in Celsius.