C Program to Convert Fahrenheit to Celsius

This program demonstrates how to convert a temperature from Fahrenheit to Celsius using C programming.

Concept Overview

Celsius and Fahrenheit are two common temperature scales. The conversion formula is C = (F - 32) * 5/9. This program takes user input in Fahrenheit and calculates the corresponding Celsius value.

Program Code

C
#include <stdio.h>

int main() {
    float fahrenheit, celsius;

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

    // Conversion formula
    celsius = (fahrenheit - 32) * 5 / 9;

    printf("%.2f Fahrenheit = %.2f Celsius\n", fahrenheit, celsius);

    return 0;
}

Output

Enter temperature in Fahrenheit: 98
98.00 Fahrenheit = 36.67 Celsius

Explanation

  • `float fahrenheit, celsius;` – Variables to store temperature values.
  • `scanf()` – Reads user input in Fahrenheit.
  • `celsius = (fahrenheit - 32) * 5 / 9;` – Converts Fahrenheit to Celsius using the formula.
  • `printf()` – Displays the converted Celsius temperature to the user.
Note: Note: Floating-point arithmetic allows decimal precision in temperature conversion.