In this tutorial, we will learn the writing program in c to convert a given temperature from celsius to Fahrenheit. This program will be simple because we have a mathematical formula for this conversion. Only we have to apply these conversion formula in the programming logic.
How our Celsius to Fahrenheit conversion program will behave?
- Our program will take a number as a input which we are considering temperature in celsius.
- Now we will use celsius to fahrenheit conversion formula which is (celsius * 9 / 5) + 32.
- After this calculation result will be temperature in fahrenheit.
C Program to convert Celsius to Fahrenheit
#include <stdio.h>
int main()
{
float celsius, fahrenheit;
printf("Program to convert Temperature from Celsius to Fahrenheit\n");
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
fahrenheit = (celsius * 9 / 5) + 32;
printf("%.2f Celsius = %.2f Fahrenheit", celsius, fahrenheit);
return 0;
}
Output
Program to convert Temperature from Celsius to Fahrenheit
Enter temperature in Celsius: 36
36.00 Celsius = 96.80 Fahrenheit
[wpusb]