This C++ program performs the conversion of temperature from Fahrenheit to celsius. The program takes the temperature in Fahrenheit degrees performs conversion to Celsius degrees using a function and prints the value on the standard output stream.
Here is the source code of the C++ program that performs the conversion of temperature from Fahrenheit to celsius. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
/* * C++ Program to Perform Fahrenheit to Celsius Conversion */ #include <iostream> double fahrenheitToCelsius(double fahrenheit) { double celsius; celsius = (fahrenheit - 32.0) * 5.0 / 9.0; return celsius; } int main() { double fahrenheit; std::cout << "Enter temperature in fahrenheit (in degrees) "; std::cin >> fahrenheit; std::cout << "Temperature in Celsius (in degrees) = " << fahrenheitToCelsius(fahrenheit) << std::endl; }
$ a.out Enter temperature in fahrenheit (in degrees) -40 Temperature in Celsius (in degrees) = -40