Q:

C Program To Convert Temperature From Celsius To Fahrenheit And Fahrenheit To Celsius

belongs to collection: Basic C Programming Examples

0

In this example, 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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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;

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

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

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Basic C Programming Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program To Find The Smallest Number Using if els... >>
<< C Program To Take Input of 5 Subject, Find Total A...