# JavaScript Program to Convert Celsius to Fahrenheit

The blog provides the step by step solution to write a JavaScript program to convert Celsius to Fahrenheit. To understand the below given program , user should have knowledge on below given topics

##### Celsius to Fahrenheit formula

The below given is the Formula to convert Celsius value to Fahrenheit

``fahrenheit = celsius * 1.8 + 32``
##### Steps to convert Celsius to Fahrenheit
• Prompt user to get the Celsius Number
• Compute Fahrenheit by using the above formula
• Display final value for Fahrenheit

## Fahrenheit to Celsius formula

The below given is the Formula to convert Fahrenheit to Celsius value

``celsius = (fahrenheit - 32) / 1.8``
##### Steps to convert Fahrenheit to Celsius
• Prompt user to get the Fahrenheit Number
• Compute Celsius by using the above formula
• Display final value for Celsius
``` <script>

let X = prompt('Enter the Celsius  number: ');
let Y = prompt('Enter the Fahrenheit number: ');

let output1 ;
let output2;

document.writeln(` Input for Celsius': \${X}` +"<br>");
document.writeln(` Input for  Fahrenheit ': \${Y}` +"<br>");

output1 = (X * 1.8) + 32; // calculates fahrenheit
output2 = (Y - 32) / 1.8  // calcluates celsius

document.writeln("----Calcualte Celsius to Fahrenheit --------"  +"<br>");
document.writeln(`Fahrenheit ': \${output1}` +"<br>");

document.writeln("----Calcualte Fahrenheit to Celsius --------"  +"<br>");
document.writeln(`celsius ': \${output2}` +"<br>");

</script>```

Output:

```Input for Celsius': 5
Input for Fahrenheit ': 1
----Calcualte Celsius to Fahrenheit --------
Fahrenheit ': 41
----Calcualte Fahrenheit to Celsius --------
celsius ': -17.22222222222222```