Knowledge Required
For conversion of degree Celsius to Fahrenheit only the mathematical expression required which is at below:
Temperature Conversion Formula
where,
C = Temperature in degree Celsius
F = Temperature in Fahrenheit
Logic Required
1. Input the value in Celsius and store in a variable (say Celsius).
2. Apply the mathematical expression and store the resultant in a variable (say Fahrenheit).
3. Finally, print the resultant value.
Full Code to Convert degree Celsius(Centigrade) to Fahrenheit
/*
Program to convert degree Celsius to Fahrenheit
*/
#include<stdio.h>
int main()
{
float Fahrenheit, Celsius;
// Input temperature in celsius
printf("Enter temperature in celsius: \n");
scanf("%f",&Celsius);
//Apply temperature conversion formula
Fahrenheit = (Celsius * 9 / 5) + 32;
// Print the resultant Fahrenheit
printf("Temperature in Fahrenheit = %.2f",Fahrenheit);
return 0;
}
%.2f is used to print the value upto two decimal places. If we simply write %f then by default it printed upto six decimal places.
\n is an escape sequence used to change the line of output.
We hope you clearly understood the above code and you are able to write how to convert degree Celsius to Fahrenheit this on your own. So, please write this code and run this code on your own and look the answer. Wow! it's amazing. So, please write and run this code on your own.
You are always welcome to write your in the comment box. Comment Us!
0 Comments