temperature conversion

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius

In this article, we will discuss the title of  the “How to write a program to convert Fahrenheit into Celsius”

In this post, we will learn how to write a program to convert Fahrenheit into  Celsius and display the result on the screen.

Generally, we know three types of temperature units Fahrenheit, Celsius, and Kelvin. Fahrenheit and Celsius are the measuring units in degrees as oF and oC respectively. In this article, we are discussing how to convert temperature units Fahrenheit into Celsius.

 

Formula 

C = F-32/1.8

 

Algorithm

  • Declare and initialize  variables
  • Apply the formula  and calculate celsius
  • Print the temperature in Celsius on the screen

 

Code to Fahrenheit into Celsius

Convert Fahrenheit into Celsius- Java

Java language

Program 1

//Java program to Solution to Convert Fahrenheit into Celsius
public class Fahrenheit_To_Celsius
{
public static void main (String args[]){
double fahre=122,cels;
//declaring variables 
cels=((fahre-32)*5/9);
//Calculate Celsius value 
//using given fahrenheit value

  System.out.print("Temperature in Celsius:"+cels);
//print the celsius value as output
}
}

When the above code is executed, it produces the following result

Temperature in Celsius:50.0

 

Convert Fahrenheit into Celsius – C

C  language

Program 2

// C program to convert Temparature
// fahrenheit into celsius
#include <stdio.h>

int main() {
    //variable declaration
    float celsius,fahrenheit;
   //decare the variables 
   fahrenheit=50;
  //initiaize variable fahrenheit
    //Convert fahrenheit into celsius
    celsius=((fahrenheit-32)*5/9);
  //Calculate fahrenheit value 
    printf("The temperature in Celsius is=%.2f ",celsius);
//display result
    return 0;
}

When the above code is executed, it produces the following result

The temperature in Celsius is=10.00

 

Convert Fahrenheit into Celsius – C++

C++ language

Program 3

//C++ program to convert F into C
#include <iostream>
using namespace std;
int main() {
    float celsius, fahrenheit;
     //declare float type variable
   fahrenheit=90.0;
  //initialize variable
    celsius=((fahrenheit-32) * 5/9);
    //Calculate celsius
  //Using equation
    cout<<fahrenheit<<" Fahrenheit is: "<<celsius <<" Celsius";
    //display result on the screen

    return 0;
}

When the above code is executed, it produces the following result

90 Fahrenheit is: 32.2222 Celsius

 

Convert Fahrenheit into Celsius – C#

C# language

Program 4

// C# program to convert Fahrenheit to Celsius

using System;
namespace temperature
{
public class FtoC
{
    public static void Main(string[] args)
    {
        double celsius,fahrenheit=98.6; 
    //variable Declaration
        celsius=((fahrenheit-32)*5/9);
    //Caculate Fahrenheit
        Console.WriteLine ("The temperature in Celsius: "+celsius);
    //print celsius 
        Console.ReadKey();
    }
}
}

When the above code is executed, it produces the following result

The temperature in Celsius: 37

 

Convert Fahrenheit into Celsius – Python

Python language

Program 5

# Python program to convert temperature in  Fahrenheit to Celsius 
fahrenheit=98.6   #Declare and initialize variabe
#Calculate celsius value
celsius=((fahrenheit-32)*5)/9

#Dispay resut
print('%0.1f degrees Fahrenheit is equal to %0.1f degree Celsius' %(fahrenheit,celsius))

When the above code is executed, it produces the following result

98.6 degrees Fahrenheit is equal to 37.0 degree Celsius

 

 

Convert Fahrenheit into Celsius – PHP

PHP language

Program 6

<?php
//PHP code to Convert Fahrenheit to Celsius degrees 
$fahrenheit=50.0;
//initialize variable
$celsius=(($fahrenheit-32)*5)/9;
//Calculate celsius
echo("The temperature in Celsius is: ");
$celsius=round($celsius,3);
echo(($celsius));
//print tesult
?>

When the above code is executed, it produces the following result

The temperature in Celsius is: 10

 

Convert Fahrenheit into Celsius – JavaScript

JavaScript language

Program 7

//program to Convert Fahrenheit to  Celsius
//Declare and initialize variable
const fahrenheit=59.0;
const celsius=(fahrenheit-32)*5/9;
//Calculate temperature of Celsius
//Display the result on the screen
console.log(`${fahrenheit} degrees Fahrenheit is equal to ${celsius} degrees Celsius.` );

When the above code is executed, it produces the following result

59 degrees Fahrenheit is equal to 15 degrees Celsius.

 

Similar post

Celsius into Fahrenheit in the C program

Fahrenheit into Celsius in C program

Celsius into Fahrenheit in C++ program

Fahrenheit into Celsius in C++ program

Celsius into Fahrenheit in the C# program

Fahrenheit into Celsius in C# program

Convert Celsius into Fahrenheit in Python

Convert Fahrenheit into Celsius in Python

Convert Celsius into Fahrenheit in PHP

Convert Fahrenheit into Celsius in PHP

Convert Celsius into Fahrenheit in JavaScript

Convert Fahrenheit into Celsius in JavaScript

Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

11 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

11 months ago

Program to convert Celsius into Fahrenheit-Entered by user

Program to convert Celsius into Fahrenheit-Entered by user In this article, we will discuss the…

11 months ago

This website uses cookies.