Easy Temperature Conversion: Fahrenheit to Centigrade

Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees.

Introduction

Temperature conversion is a common need, especially when dealing with weather data or international temperature scales. Converting Fahrenheit to Centigrade (also known as Celsius) degrees is a simple yet useful task. In this article, we will guide you through the process of writing a program to convert a temperature in Fahrenheit, entered via the keyboard, into Centigrade degrees. This program will be written in a user-friendly manner using the C programming language.

Understanding the Conversion Formula

Before we delve into the implementation, let’s understand the conversion formula between Fahrenheit and Centigrade degrees. The formula for converting a temperature from Fahrenheit (F) to Centigrade (C) is as follows:

C = (F - 32) * 5/9

Implementing the Conversion in C

Let’s now write a C program to perform the temperature conversion:

#include <stdio.h>

int main() {
    // Declare variables to store Fahrenheit and Centigrade temperatures
    float fahrenheitTemp, centigradeTemp;

    // Input temperature in Fahrenheit from the keyboard
    printf("Enter the temperature in Fahrenheit: ");
    scanf("%f", &fahrenheitTemp);

    // Convert Fahrenheit to Centigrade using the conversion formula
    centigradeTemp = (fahrenheitTemp - 32) * 5 / 9;

    // Output the converted temperature
    printf("The temperature in Centigrade is: %.2f\n", centigradeTemp);

    return 0;
}

Explanation

  1. We begin by including the required header file for input/output operations (stdio.h).
  2. Next, we declare two variables to store the temperature in Fahrenheit and the converted temperature in Centigrade.
  3. The program prompts the user to input the temperature in Fahrenheit using the scanf() function.
  4. The conversion from Fahrenheit to Centigrade is performed using the conversion formula mentioned earlier.
  5. The converted temperature in Centigrade is then displayed on the screen with two decimal places using the printf() function.

Conclusion

In conclusion, converting temperatures between Fahrenheit and Centigrade is a valuable skill for various applications, from weather reporting to scientific calculations. With this C program, you can quickly and accurately convert temperatures entered through the keyboard from Fahrenheit to Centigrade degrees. The simple implementation of the conversion formula enables users to make conversions effortlessly. Whether you’re a student, researcher, or weather enthusiast, having the ability to convert temperatures will prove useful in your endeavors. So, use this handy C program to perform temperature conversions with ease and efficiency!

Leave a Comment