C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius
In this article, we are going to write a c program to Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius.
first, we will convert Celsius to Fahrenheit and in the second we will convert Fahrenheit to Celsius. But first of all, you need to know what is Celsius and Fahrenheit and what is its formula.
Introduction About Celsius And Fahrenheit
Celsius is represented by oC and Fahrenheit is represented by oF. There is a formula to convert Celsius to Fahrenheit, using which we will be able to convert Celsius to Fahrenheit.
Similarly, there is also a formula to convert Fahrenheit to Celsius, using which we will be able to convert Fahrenheit to Celsius.
Formula to Convert Temperature From Celsius To Fahrenheit
Fahrenheit = (celsius * 1.8) + 32
Formula to Convert Temperature From Fahrenheit to Celsius
Celsius = ((Fahrenheit-32)*5)/9;
Now without wasting time let’s start programming.
C Program To Convert Temperature From Celsius To Fahrenheit (Simple Way)
Algorithm-:
- Program Start
- Declaration of variable
- Enter temperature in Celsius
- Fahrenheit conversion formula
- Print result
- Program End
Flowchart
Program
//C Program To Convert Temperature From Celsius To Fahrenheit
#include<stdio.h>
void main()
{
float c, f;
printf("Enter Temperature\n");
scanf("%f",&c);
//Temperature From Celsius To Fahrenheit
f=(c*9/5)+32;
printf("Temperature in Fahrenheit is : %f",f);
return 0;
}
Output
Enter Temperature
37
Temperature in Fahrenheit is : 98.599998
Write A C Program to Convert Temperature From Fahrenheit to Celsius (Simple Way)
Algorithm-:
- Program Start
- Declaration of variable
- Enter temperature in Fahrenheit
- Converting Fahrenheit into Celsius
- Print result
- Program End
Program
//Write A C Program to Convert Temperature From Fahrenheit to Celsius
#include<stdio.h>
int main()
{
float c, f;
printf("Enter Temperature in Fahrenheit : ");
scanf("%f",&f);
//Converting Fahrenheit into Celsius
c = ((f-32)*5)/9;
printf("Temperature in Celsius is : %f",c);
return 0;
}
Output
Enter Temperature in Fahrenheit
98.5
Temperature in Celsius is : 36.94
C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius (Simple Way)
Algorithm-:
- Program Start
- Declaration of variable
- Enter temperature in Celsius
- Enter temperature in Fahrenheit
- Converting conversion into Fahrenheit
- Converting Fahrenheit into Celsius
- Displaying result
- Program End
Program
//C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius
#include<stdio.h>
int main()
{
float t1, t2,c,f;
printf("Enter Temperature in Celsius : ");
scanf("%f",&t1);
printf("\nEnter Temperature in Fahrenheit : ");
scanf("%f",&t2);
//Temperature From Celsius To Fahrenheit
f=(t1*9/5)+32;
//Converting Fahrenheit into Celsius
c = ((t2-32)*5)/9;
printf("\nTemperature in Fahrenheit : %f",f);
printf("\nTemperature in Celsius : %f",c);
return 0;
}
Output -:
Enter Temperature in Celsius : 37
Enter Temperature in Fahrenheit : 98
Temperature in Fahrenheit : 98.599998
Temperature in Celsius : 36.666668
C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius Using Function
To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius Using Function, first you need to know about the function. You can read about the function from the link given below.
Algorithm-:
- Program Start
- Declaration of variable
- Enter temperature in Celsius
- Calling Functions to Convert Celsius to Fahrenheit and Fahrenheit to Celsius
- Display result
- Program End
Program
//C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius Using Function
#include<stdio.h>
float covces(float t)
{
return ((t*9/5)+32);
}
float covfeh(float t)
{
return (((t-32)*5)/9);
}
int main()
{
float t1, t2,c,f;
printf("Enter Temperature in Celsius : ");
scanf("%f",&t1);
printf("\nEnter Temperature in Fahrenheit : ");
scanf("%f",&t2);
//Calling Function to convert Temperature From Celsius To Fahrenheit
f = covces(t1);
//Calling Function to convert Temperature From Fahrenheit To Celsius
c = covfeh(t2);
//Display Result
printf("\nTemperature in Fahrenheit : %f",f);
printf("\nTemperature in Celsius : %f",c);
return 0;
}
Output -:
Enter Temperature in Celsius : 37
Enter Temperature in Fahrenheit : 98
Temperature in Fahrenheit : 98.599998
Temperature in Celsius : 36.666668
Read More
- Download C Language Notes Pdf
- C Language Tutorial For Beginners
- C Programming Examples With Output
- 250+ C Programs for Practice PDF Free Download
Conclusion
In this article, we have created all the following programs -:
- C Program To Convert Temperature From Celsius To Fahrenheit
- Write A C Program to Convert Temperature From Fahrenheit to Celsius
- C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius
- C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius Using Function
If you have difficulty to understand any program or have any doubts or questions, then tell me in the comment below.