calculations

JavaScript code: Convert Celsius degrees to Fahrenheit

JavaScript code: Convert Celsius degrees to Fahrenheit

In this article, we will discuss the concept of  the “JavaScript code: Convert Celsius degrees to Fahrenheit”

In this post, we will learn how to write a program to convert Celsius into Fahrenheit and display the result on the screen in JavaScript language. Here, we have four methods and explain how to calculate Fahrenheit using the given Celsius value and display the result on the screen in the JavaScript programming language

Code to Celsius into Fahrenheit

Convert Celsius into Fahrenheit -#1

In this program, the user declares two variables as Celsius and Fahrenheit and initiates the value as 75.0 to the variable- Celsius. The scientific equation will convert it from Celsius into Fahrenheit in the JavaScript programming language.

Program 1

//Code to Convert Celsius to Fahrenheit 
//Declare and initialize variable Celsius
const celsius=75;
const fahrenheit=(celsius*1.8)+32
//Caculate Fahrenheit uaing scientific equation
//Display the result on the screen
console.log(`${celsius} degrees Celsius is equal to ${fahrenheit } degrees Fahrenheit.` );

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

75 degrees Celsius is equal to 167 degrees Fahrenheit.

 

Convert Celsius into Fahrenheit -Entered by the user-#2

In this program, the user declares two variables as Celsius and Fahrenheit. The program asks for input from the user to Celsius then the given value will be converted from Celsius into Fahrenheit in the JavaScript programming language using the scientific equation.

Program 2

//Code to Convert Celsius to Fahrenheit 
//Ask input from the user
const celsius=prompt("Enter a Celsius value: ");
const fahrenheit=(celsius*1.8)+32
//Caculate Fahrenheit uaing scientific equation
//Display the result on the screen
console.log(`${celsius} degree Celsius is equal to ${fahrenheit } degrees Fahrenheit.` );

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

Enter a Celsius value: 98
98 degree Celsius is equal to 208.4 degrees Fahrenheit.

 

Convert Celsius into Fahrenheit Using function-#3

In this program, the user declares an int variable as a parameter for Celsius(celsius) in the user-defined function. When the user runs the program (when calling the function), the value for Celsius passes as an argument to the function via variable.
Finally, the Fahrenheit value is calculated and displayed on the screen using the scientific equation in the JavaScript programming language.

Program 3

//Code to Convert Celsius to Fahrenheit 
//Using a user-defined function
function CelsTofahre(c){
  //function definition
    return (celsius*1.8)+32
    
}
//Declare and initialize variable
const celsius=60;
//Calling the function to output
var result=CelsTofahre(celsius)
//Display the result
console.log(`${celsius} degree Celsius is equal to ${result} degrees Fahrenheit .` );

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

60 degree Celsius is equal to 140 degrees Fahrenheit

 

Convert Celsius into Fahrenheit Using function-#4

In this program, the user declares an int variable as a parameter for Celsius(celsius) in the user-defined function. When the user runs the program (when calling the function), The program asks for input from the user for Celsius and the value for Celsius passes as an argument to the function through the variable.
Finally, the Fahrenheit value is calculated and displayed on the screen using the scientific equation in the JavaScript programming language.

Program 4

//Code to Convert Celsius to Fahrenheit 
//Using a user-defined function
function CelsTofahre(c){
  //function definition
    return (celsius*1.8)+32
    
}
//Declare and initialize variable
const celsius=prompt("Enter a Celsius value: ");
//Calling the function to output
var result=CelsTofahre(celsius)
//Display the result
console.log(`${celsius} degree Celsius is equal to ${result} degrees Fahrenheit .` );

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

Enter a Celsius value: 66
66 degree Celsius is equal to 150.8 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.