Write a C Program to convert Fahrenheit to Celsius.

Prince Patel
By -
0

Write a C Program to convert Fahrenheit to Celsius.



Here's a C program to convert Fahrenheit to Celsius :

#include<stdio.h>
#include<conio.h>

void main()
{
    float fahrenheit, celsius;

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

    // Convert Fahrenheit to Celsius
    celsius = (fahrenheit - 32) * 5 / 9;

    // Display the result
    printf("Temperature in Celsius: %.2f\n", celsius);
}


  • we take the temperature in Fahrenheit as input from the user, then we use the formula (°F - 32) * 5/9 to convert it to Celsius. 
  • Finally, we display the result in Celsius
  • The %.2f format specifier is used to print the floating-point values with two decimal places for better readability
Output:



Tags:

Post a Comment

0Comments

Post a Comment (0)