Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
Using function / method to Write temperature conversion : Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius

Posted on June 27, 2023

Table of Contents

  • How to write a program to convert Fahrenheit into Celsius
    • Code to Fahrenheit into Celsius
      • Convert Fahrenheit into Celsius- Java
      • Convert Fahrenheit into Celsius – C
      • Convert Fahrenheit into Celsius – C++
      • Convert Fahrenheit into Celsius – C#
      • Convert Fahrenheit into Celsius – Python
      • Convert Fahrenheit into Celsius – PHP
      • Convert Fahrenheit into Celsius – JavaScript

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

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes