C Program to Convert Fahrenheit to Celsius

Here’s a C program that converts Fahrenheit to Celsius:

				
					#include <stdio.h>

int main() {
    double fahrenheit, celsius;

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

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

    printf("Temperature in Celsius: %.2lf\n", celsius);

    return 0;
}

				
			
Output
Convert Fahrenheit to Celsius using C Program
  • Explanation:

    • The program starts by including the stdio.h header file, which provides the necessary functions for input and output operations in C.
    • Inside the main function, we declare the variables fahrenheit and celsius as doubles to store the respective values.
    • We prompt the user to enter the temperature in Fahrenheit using a printf statement, and we read their input using a scanf statement.
    • The temperature is converted from Fahrenheit to Celsius using the formula: celsius = (fahrenheit - 32) * 5 / 9.
    • Finally, we use a printf statement to display the temperature in Celsius with two decimal places.

    When you run this program, it will prompt you to enter the temperature in Fahrenheit. After you provide the input, it will calculate and display the equivalent temperature in Celsius.