This C++ program performs conversion of temperature from fahrenheit to celsius. The program takes temperature in fahrenheit degrees performs conversion to celsius degrees using a function and prints the value on standard output stream.
Here is the source code of the C++ program performs 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
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
advertisement
advertisement
If you wish to look at all C++ Programming examples, go to C++ Programs.
If you find any mistake above, kindly email to [email protected]Related Posts:
- Check Programming Books
- Check C++ Books
- Practice Programming MCQs
- Apply for C++ Internship
- Apply for Computer Science Internship