How to make C program to convert Fahrenheit into Celsius
How to make C program to convert Fahrenheit into Celsius
Temperature conversion formula
Temperature conversion formula from degree Celsius to Fahrenheit is given by -
Celsius = 5/9(Farenhite - 32)
The logic to convert temperature from Celsius to Fahrenheit
The logic of temperature conversion exists in converting the mathematical formula to C expression. You just need to convert mathematical formula of temperature in C language. Rest is simple input/output.
Below is the step by step descriptive logic to convert temperature from degree Celsius to Fahrenheit.
- Input temperature in Celsius from the user. Store it in some variable say celsius.
- Apply formula to convert the temperature to Fahrenheit i.e.
fahrenheit = (celsius * 9 / 5) + 32
- Print the value of Fahrenheit.
Program to convert temperature from Celsius to Fahrenheit
/**
* C program to convert temperature from degree celsius to fahrenheit
*/
#include <stdio.h>
int main()
{
float celsius, fahrenheit;
/* Input temperature in celsius */
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
/* celsius to fahrenheit conversion formula */
fahrenheit = (celsius * 9 / 5) + 32;
printf("%.2f Celsius = %.2f Fahrenheit", celsius, fahrenheit);
return 0;
}
Comments
Post a Comment