Friday, 28 March 2014
1
C Program 6: To convert the temperature from Fahrenheit to Celsius.
Aim: Temperature of a city in Fahrenheit degree is input through the keyboard. Write a program to convert this temperature into Centigrade degrees.
Theory: This is one of the basic programs that one should know to make in the C but the only tough part is remembering the formula for conversion of temperature from one scale to another. There is no logic in that. It's just a mathematical formula which you need to keep in mind. The Formula is C= 5(F+32)/9
Code:
//to convert temperature from Fahrenheit to Celsius
#include<stdio.h>
#include<conio.h>
int main()
{
float fahf, celf;
printf("Enter the temperature in Fahrenheit: ", fahf);
scanf("%f", &fahf);
celf=5*(fahf-32)/9;
printf("The temperature in Celsius is: %f", celf);
getch();
return 0;
}
We just took two variables and then used the formula which I mentioned above in the theory portion. Here's the output:
Subscribe to:
Post Comments (Atom)
1 Responses to “C Program 6: To convert the temperature from Fahrenheit to Celsius.”
12 April 2020 at 10:28
Read next: C Program to Convert Temperature Celsius to Fahrenheit
Post a Comment