Fahrenheit and Centigrade are both the unit of temperature in which they tells us the degree of hotness and coldness. The difference between them is that
Centigrade = (Fahrenheit – 32) x (5.0 / 9.0)
So using the above formula we will write a C++ program that will convert Fahrenheit to Centigrade
#include <iostream> #include <conio.h> using namespace std; int main() { float cen, fah; cout<<"Convert Fahrenheit to Centigrade"<<endl; cout<<"Fahrenheit: "; cin>>fah; cen=(fah-32)*(5.0/9.0); cout<<fah<<" Fahrenheit = "<<cen<<" Centigrade"; getch(); return 0; }
Explanation
We declare the float cen for Centigrade and fah for Fahrenheit as temperature can have decimal value
The program ask for Fahrenheit value from the user and convert it to Centigrade in the line 10 and it print the output
N.B. In line 10 do not remove the zero from 5.0 or 9.0 because it will give an error as it is a float value
Compiler Used: Code Blocks