How to convert fahrenheit to celsius in C

3 Answers

0 votes
#include <stdio.h> 

float FahrenheitToCelsius(float f);

int main(int argc, char **argv) 
{
    float temp_f, temp_c;

    printf("Enter Temperature in Fahrenheit: ");
    scanf("%f", &temp_f);
    temp_c = FahrenheitToCelsius(temp_f);
    printf("%.2f Fahrenheit = %.2f celsius\n",temp_f, temp_c);

    return(0);
}
float FahrenheitToCelsius(float f)
{
    float t;
    
    t = (f - 32) / 1.8;
    
    return(t);
}


/*
run1:

Enter Temperature in Fahrenheit: 1
1.00 Fahrenheit = -17.22 celsius

run2:

Enter Temperature in Fahrenheit: 50
50.00 Fahrenheit = 10.00 celsius

*/


answered Apr 30, 2015 by avibootz
0 votes
#include <stdio.h> 

float FahrenheitToCelsius(float f);

int main(int argc, char **argv) 
{
    float temp_f,temp_c;

    printf("Enter Temperature in Fahrenheit: ");
    scanf("%f", &temp_f);
    temp_c = FahrenheitToCelsius(temp_f);
    printf("%.2f Fahrenheit = %.2f celsius\n",temp_f, temp_c);

    return(0);
}
float FahrenheitToCelsius(float f)
{
    float t;
    
    t = (f - 32) * (5.0/9.0);
    
    return(t);
}


/*
run1:

Enter Temperature in Fahrenheit: 1
1.00 Fahrenheit = -17.22 celsius

run2:

Enter Temperature in Fahrenheit: 50
50.00 Fahrenheit = 10.00 celsius

*/


answered May 1, 2015 by avibootz
0 votes
#include <stdio.h>
  
int main(void) {
    int fahrenheit = 96;
      
    double celsius = (fahrenheit - 32) * 5 / 9.0;
      
    printf("Celsius = %f", celsius);
}
  
  
  
  
/*
run:
    
Celsius = 35.555556
   
*/

 



answered Jul 22, 2022 by avibootz

Related questions

1 answer 215 views
1 answer 218 views
1 answer 327 views
327 views asked Jul 15, 2021 by avibootz
1 answer 235 views
1 answer 196 views
1 answer 273 views
273 views asked Jul 15, 2021 by avibootz
1 answer 303 views
...