temperature conversion

Write a Program to convert Celsius into Fahrenheit

Write a Program to convert Celsius into Fahrenheit

In this article, we will discuss the title of  the “Write a Program to convert Celsius into Fahrenheit”

In this post, we will learn how to write a program to convert Celsius into Fahrenheit 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 

F=C x 9/5 + 32

 

Algorithm

  • Declare and initialize  variables
  • Apply the formula
  • Print the temperature in Fahrenheit on the screen

 

Code to Celsius into Fahrenheit

Convert Celsius into Fahrenheit – Java

Java language

public class Celsius_To_Fahrenheit
{
public static void main (String args[]){
//variables decaration as double
double fahre,cels=60; 
fahre=(cels*9/5)+32;
//Calculate Fahrenheit value
//using scientiic equation

  System.out.print("Temperature in Farhenheit:"+fahre);
//print the resut
}
}

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

Temperature in Farhenheit:140.0

 

Convert Celsius into Fahrenheit – C

C language

// Program to convert celsius into fahrenheit
#include <stdio.h>

int main() {
    // declaring float type variables
    float celsius,fahrenheit;
    //initializing variables celsius
    celsius=70;
    //Convert celsius to fahrenheit
    fahrenheit=((celsius*9/5)+32);
    printf("%.2f Temperature in Fahrenheit is=%.2f ",celsius,fahrenheit);
//Print the result on the screen
    return 0;
}

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

70.00 Temperature in Fahrenheit is=158.00

 

Convert Celsius into Fahrenheit – C++

C++ language

//C++ code to convert Celsius into Fehrenheit
#include <iostream>
using namespace std;
int main() {
    float celsius, fehrenheit;
    //declare float type variables
    //initialize variable to celsius
    celsius=74.0;
    //Calculate fehrenheit from celsius
    fehrenheit=(celsius * 9/5)+32;
    cout<<celsius<<" Celsius is: "<<fehrenheit <<" Fehrenheit";
    //display result on the screen

    return 0;
}

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

74 Celsius is: 165.2 Fehrenheit

 

Convert Celsius into Fahrenheit – C#

C#  language

// C# program to convert Celsius to Fahrenheit
using System;
namespace temperature
{
public class CelstoFahr
{
    public static void Main(string[] args)
    {
        double celsius,fahrenheit; 
    //Declare variables as double
        celsius=90.00;
    //initialize value to Celsius
        fahrenheit=(1.8*celsius)+32;
    //Caculate Fahrenheit using scientific equation
        Console.WriteLine ("The temperature in Fahrenheit is: "+fahrenheit);
    //Display result
        Console.ReadKey();
    }
}
}

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

The temperature in Fahrenheit is: 194

 

Convert Celsius into Fahrenheit – Python

Python

# Python program to convert temperature in Celsius to Fahrenheit
celsius=75.0
#initialize variabe

#Calculate Fahrenheit
fahrenheit=(celsius*1.8)+32
#print reslut
print('%0.1f degree Celsius is equal to %0.1f degrees Fahrenheit' %(celsius,fahrenheit))

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

75.0 degree Celsius is equal to 167.0 degrees Fahrenheit

 

Convert Celsius into Fahrenheit – PHP

PHP

<?php
//php code to convert Celsius to Fahrenheit
$celsius=90.0;
//declare and initilize variable
$fahrenheit=(($celsius*9)/5)+32;
//Calculate Fahrenheit
echo("Temperature in Fahrenheit is: ");
echo(($fahrenheit));
//Print the temperature in Fahrenheit
?>

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

Temperature in Fahrenheit is: 194

 

Convert Celsius into Fahrenheit – JavaScript

JavaScript

//Program to Convert Celsius to Fahrenheit 
//declare and initialize variable
const celsius=32
const fahrenheit=(celsius*1.8)+32
//Calculate Fahrenheit
//Display the result
console.log(`${celsius} degree celsius is equal to ${fahrenheit } degrees Fahrenheit.` );

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

32 degree Celsius is equal to 89.6 degrees Fahrenheit.

 

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

Subtract two numbers using method overriding

Subtract two numbers using method overriding   Program 1

3 months ago

PHP Star triangle Pattern program

PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…

3 months ago

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,…

1 year 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…

1 year ago

Write temperature conversion program: Fahrenheit into Celsius

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

1 year ago

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…

1 year ago

This website uses cookies.