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 And Fahrenheit To Celsius

C Program To Convert Temperature From Celsius To Fahrenheit (Simple Way)

Algorithm-:

  1. Program Start
  2. Declaration of variable
  3. Enter temperature in Celsius
  4. Fahrenheit conversion formula
  5. Print result
  6. Program End

Flowchart

C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius - 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-:

  1. Program Start
  2. Declaration of variable
  3. Enter temperature in Fahrenheit
  4. Converting Fahrenheit into Celsius
  5. Print result
  6. 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-:

  1. Program Start
  2. Declaration of variable
  3. Enter temperature in Celsius
  4. Enter temperature in Fahrenheit
  5. Converting conversion into Fahrenheit
  6. Converting Fahrenheit into Celsius
  7. Displaying result
  8. 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-:

  1. Program Start
  2. Declaration of variable
  3. Enter temperature in Celsius
  4. Calling Functions to Convert Celsius to Fahrenheit and Fahrenheit to Celsius
  5. Display result
  6. 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

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.

Jeetu Sahu is A Web Developer | Computer Engineer | Passionate about Coding, Competitive Programming, and Blogging

Leave a Comment