Reference Materials
Certification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
Javascript Program to Convert Celsius to Fahrenheit
In this example, you will learn to convert Celsius value to Fahrenheit in JavaScript.
To understand this example, you should have the knowledge of the following JavaScript programming topics:
You can convert the celsius value to fahrenheit by using the formula:
fahrenheit = celsius * 1.8 + 32
Example: Celsius to Fahrenheit
// program to convert celsius to fahrenheit
// ask the celsius value to the user
const celsius = prompt("Enter a celsius value: ");
// calculate fahrenheit
const fahrenheit = (celsius * 1.8) + 32
// display the result
console.log(`${celsius} degree celsius is equal to ${fahrenheit} degree fahrenheit.`);
Output
Enter a celsius value: 55 55 degree celsius is equal to 131 degree fahrenheit.
In the above program, the user enters the celsius value and is stored in the celsius variable. Then the fahrenheit formula is used to convert celsius value to fahrenheit.
You can convert fahrenheit value to celsius using the formula:
celsius = (fahrenheit - 32) / 1.8
Also Read:
Did you find this article helpful?