Table of Contents
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
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
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
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
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
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
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
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
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…
This website uses cookies.