- 1C Hello World Program
- 2C Program to Print Your Own Name
- 3C Program to Print an Integer Entered by the User
- 4C Program to Add Two Numbers
- 5C Program to Multiply Two Floating‑Point Numbers
- 6C Program to Print the ASCII Value of a Character
- 7C Program to Swap Two Numbers
- 8C Program to Calculate Fahrenheit to Celsius
- 9C Program to Find the Size of int, float, double and char
- 10C Program - Add Two Complex Numbers
- 11C Program - Find Simple Interest
- 12C Program - Find Compound Interest
- 13C Program - Area And Perimeter Of Rectangle
- 14C Program - Check Whether a Number is Positive, Negative, or Zero
- 15C Program - Check Whether Number is Even or Odd
- 16C Program - Check Whether a Character is Vowel or Consonant
- 17C Program - Find Largest Number Among Three Numbers
- 18C Program - Calculate Sum of Natural Numbers
- 19C Program - Print Alphabets From A to Z Using Loop
- 20C Program - Make a Simple Calculator
- 21C Program - Generate Multiplication Table
- 22C Program - Reverse a Number
- 23C Program - Check whether the input number is a Neon Number
- 24C Program - Find All Factors of a Natural Number
C Program to Convert Fahrenheit to Celsius - Formula & Function
Convert Fahrenheit to Celsius Using Formula
#include <stdio.h>
int main() {
float fahrenheit, celsius;
printf("Enter temperature in Fahrenheit: ");
scanf("%f", &fahrenheit);
celsius = (fahrenheit - 32) * 5 / 9;
printf("Temperature in Celsius = %.2f\n", celsius);
return 0;
}
Enter temperature in Fahrenheit: 100
Temperature in Celsius = 37.78
The Celsius temperature is computed by subtracting 32 from the Fahrenheit value and multiplying the difference by 5/9. This formula works for any numeric input.
Convert Fahrenheit to Celsius Using a Function
#include <stdio.h>
float fahrenheit_to_celsius(float f) {
return (f - 32.0f) * 5.0f / 9.0f;
}
int main() {
float f;
printf("Enter temperature in Fahrenheit: ");
scanf("%f", &f);
printf("Temperature in Celsius = %.2f\n", fahrenheit_to_celsius(f));
return 0;
}
Enter temperature in Fahrenheit: 50
Temperature in Celsius = 10.00
Encapsulating the conversion in a separate function improves reusability. The function subtracts 32 from the input, multiplies by 5/9 and returns the result.
⬅ Previous TopicC Program to Swap Two Numbers
Next Topic ⮕C Program to Find the Size of int, float, double and char
Next Topic ⮕C Program to Find the Size of int, float, double and char
Comments
Loading comments...