c++ program to convert fahrenheit to celsius

#include <iostream>

int main() {
    float fahrenheit, celsius;

    std::cout << "Enter temperature in Fahrenheit: ";
    std::cin >> fahrenheit;

    celsius = (fahrenheit - 32) * 5 / 9;

    std::cout << "Temperature in Celsius: " << celsius << std::endl;

    return 0;
}
  • The #include <iostream> statement includes the necessary header file for input/output operations.
  • The main() function is the entry point of the program.
  • We declare two variables fahrenheit and celsius to store the temperature values.
  • The std::cout statement is used to display the prompt asking the user to enter the temperature in Fahrenheit.
  • The std::cin statement reads the user input and stores it in the fahrenheit variable.
  • The formula (fahrenheit - 32) * 5 / 9 is used to convert Fahrenheit to Celsius.
  • The std::cout statement is used to display the converted temperature in Celsius.
  • The return 0 statement indicates that the program has successfully executed and terminates the program.