convert Fahrenheit into Celsius
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
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.