Fahrenheit to Celsius is a temperature conversion formula used to convert temperatures measured in degrees Fahrenheit (°F) to degrees Celsius (°C) and vice-versa. In this article, we are going to learn how to write a C programming to perform this conversion.
Fahrenheit to Celsius Conversion:
To convert Fahrenheit to Celsius, subtract 32 from the Fahrenheit temperature and then multiply the result by 5/9. The formula is as follows:
Celsius = (Fahrenheit - 32) * 5/9
For example, if the user inputs 68 degrees Fahrenheit, the conversion would be:
Celsius = (68 - 32) * 5/9 = 20 degrees Celsius.
Celsius to Fahrenheit Conversion:
To convert Celsius to Fahrenheit, multiply the Celsius temperature by 9/5 and then add 32. The formula is as follows:
Fahrenheit = (Celsius * 9/5) + 32
For example, if the user inputs 25 degrees Celsius, the conversion would be:
Fahrenheit = (25 * 9/5) + 32 = 77 degrees Fahrenheit.
C program to convert temperature from Fahrenheit to Celsius.
//C program to calculate celsius from fahrenheit #include <stdio.h> int main() { float fahrenheit, celsius; // Input the temperature in Fahrenheit printf("Enter the temperature: "); scanf("%f", &fahrenheit); // Fahrenheit to Celsius conversion celsius = (fahrenheit - 32) * 5 / 9; printf("%.2f degrees Fahrenheit is equal to %.2f degrees Celsius.\n",
fahrenheit, celsius); return 0; }
Enter the temperature: 34
34.00 degrees Fahrenheit is equal to 1.11 degrees Celsius.
C program to convert temperature from Celsius to Fahrenheit.
//C program to calculate fahrenheit from celsius #include <stdio.h> int main() { float fahrenheit, celsius; // Input the temperature in celsius printf("Enter the temperature: "); scanf("%f", &celsius); // Celsius to Fahrenheit conversion fahrenheit = (celsius * 9 / 5) + 32; printf("%.2f degrees Celsius is equal to %.2f degrees Fahrenheit.\n",
celsius, fahrenheit); return 0; }
Enter the temperature: 32
32.00 degrees Celsius is equal to 89.60 degrees Fahrenheit.
No comments:
Post a Comment