C++ program to enter the temperature in Fahrenheit and convert it to Celsius
ADVERTISEMENTS
C++ program to enter the temperature in Fahrenheit and convert it to Celsius. There are you will learn how to convert the temperature in Fahrenheit and convert it to Celsius in C++ language.
Formula:
C = (F - 32) * 5/9
Where:
F = fahrenheit
C = celsius
Let us understand this example through C++ program:
/* C++ program to convert the temperature from degree fahrenheit to celsius */
#include <iostream>
using namespace std;
int main()
{
float c, f;
// c = celsius
// f = fahrenheit
cout << "Enter the temperature in Fahrenheit::\n";
cin >> f;
/* Conversion of fahrenheit to celsius */
c = (float)((f - 32) * 5 / 9);
// Output
cout << "\n" << f << " Fahrenheit = " << c << " Celsius\n";
return 0;
}
Output Screen:
Enter the temperature in Fahrenheit::
7
7 Fahrenheit = -13.8889 Celsius