C program to convert temperature from degree fahrenheit to celsius

Write a C program to input temperature in degree Fahrenheit and convert it to degree Centigrade. How to convert temperature from Fahrenheit to Celsius in C programming. C program for temperature conversion. Logic to convert temperature from Fahrenheit to Celsius in C program.

Example
Input

Temperature in fahrenheit = 205

Output

Temperature in celsius = 96.11 C

Required knowledge

Arithmetic operators, Variables and expressions, Data types, Data types

Temperature conversion formula

Formula to convert temperature from degree Fahrenheit to degree Celsius is given by –
Fahrenheit to Celsius conversion formula

Logic to convert temperature from Fahrenheit to Celsius

Step by step descriptive logic to convert temperature from degree Fahrenheit to degree Celsius –

  1. Input temperature in fahrenheit from user. Store it in some variable say fahrenheit.
  2. Apply the temperature conversion formula celsius = (fahrenheit - 32) * 5 / 9.
  3. Print the value of celsius.

Read more – Program to convert temperature from Celsius to Fahrenheit

Program to convert temperature from fahrenheit to celsius

/**
 * C program to convert temperature from degree fahrenheit to celsius
 */

#include <stdio.h>

int main()
{
    float celsius, fahrenheit;

    /* Input temperature in fahrenheit */
    printf("Enter temperature in Fahrenheit: ");
    scanf("%f", &fahrenheit);

    /* Fahrenheit to celsius conversion formula */
    celsius = (fahrenheit - 32) * 5 / 9;

    /* Print the value of celsius */
    printf("%.2f Fahrenheit = %.2f Celsius", fahrenheit, celsius);

    return 0;
}

%.2f is used to print fractional values only up to two decimal places. You can also use %f to print fractional values normally up to six decimal places.

Output

Enter temperature in Fahrenheit: 205
205.00 Fahrenheit = 96.11 Celsius

Happy coding 😉