Write a program in C to convert Fahrenheit into Celsius

Write a program in c to convert Fahrenheit into Celsius. In this article, we will create a program in C language to convert Fahrenheit into Celsius.

Introduction

There is a parameter to measure the heat or warmness of a body or thing we call temperature. Temperature is measured in different aspects like Celsius, Fahrenheit, kelvin, reamer, Delisle, and many other aspects based on the work the temperature is using for like in chemistry labs temperature is used in kelvin majorly and in weather, department temperature is always measured in celsius. Each of the measuring aspects has its own notation they are as follows:

Celsius = °C

Fahrenheit = °F

Kelvin = K

Reamur = °Ra

Delishle = °D

Algorithm

  • Start
  • Declare two variables.
  • Take input from the user.
  • Convert the temperature from Fahrenheit into Celsius using the formula: ((fahrenheit-32)*5/9)
  • Now print the value obtained.
  • End

C Program to convert Fahrenheit into Celsius

#include<stdio.h>
int main(){
  float fahrenheit;
  float celsius;
  printf("enter the temperture in fahrenheit ");
  scanf("%f",&fahrenheit);
  printf("entered temperature is %f \n",fahrenheit);
  celsius=((fahrenheit-32)*5/9);
    printf("temperature in celsius is: %f",celsius);
    return 0;
}

Explanation of the Code

  • On-Line no:1 we include all the library to take input and output
  • On-Line no:2, declaring the main method with int as its return type
  • On-Line no:3 and line 4, declaring both the variable as Fahrenheit and celsius
  • On-Line no:5 we print  a statement to on interface to instruct the user to give input,
  • On-Line no:6 we use scanf function to take the input and assign the given value in a respected variable using an ampersand (“&”).
  • On-Line no:7 we give a general recheck statement to check what the user has inputted.
  • On-Line no:8 putting the input in the formula and assign it to a variable named celsius 
  •  In the next line, we gave the output with an appropriate message.
  • On-Line no: 10, as we defined the main method as int type we need to give its return type also here we give the return type as 0.

Output

In this way, we create a program in C to convert Fahrenheit into Celsius.