Celsius to Fahrenheit and Fahrenheit to Celcius conversion is probably the most confusing conversion. But you can convert the temperatures easily if you understand the process of conversion properly.

In this article, you'll learn how to convert temperature in Celcius to Fahrenheit—and vice-versa.

How to Convert Temperature in Celcius to Fahrenheit

You can convert the temperature in Celcius to Fahrenheit using the following formula:

 T(°F) = T(°C) × 9/5 + 32

You need to multiply the °C temperature by 9/5 and add 32 to it. The result will be in °F.

Problem Statement

You're given a temperature num in °C, you need to convert it into °F. Example 1: Let num = 100. Therefore, the temperature in °F = (100 x 9/5) + 32 = 212 Thus, the output is 212. Example 2: Let num = 0. Therefore, the temperature in °F = (0 x 9/5) + 32 = 32 Thus, the output is 32.

C++ Program to Convert Temperature in Celcius to Fahrenheit

Below is the C++ program for Celcius to Fahrenheit conversion:

// C++ program to convert temperature in Celcius to Fahrenheit
#include <iostream>
using namespace std;
// Function to convert temperature in Celcius to Fahrenheit
float celciusToFahrenheit(float num)
{
return ((num * 9.0 / 5.0) + 32.0);
}
int main()
{
float num1 = 100.0;
cout << "Temperature in Celcius: " << num1 << endl;
cout << "Temperature in Fahrenheit: " << celciusToFahrenheit(num1) << endl;
float num2 = 0;
cout << "Temperature in Celcius: " << num2 << endl;
cout << "Temperature in Fahrenheit: " << celciusToFahrenheit(num2) << endl;
float num3 = 65.0;
cout << "Temperature in Celcius: " << num3 << endl;
cout << "Temperature in Fahrenheit: " << celciusToFahrenheit(num3) << endl;
float num4 = 150.0;
cout << "Temperature in Celcius: " << num4 << endl;
cout << "Temperature in Fahrenheit: " << celciusToFahrenheit(num4) << endl;
float num5 = 20.0;
cout << "Temperature in Celcius: " << num5 << endl;
cout << "Temperature in Fahrenheit: " << celciusToFahrenheit(num5) << endl;
return 0;
}

Output:

Temperature in Celcius: 100
Temperature in Fahrenheit: 212
Temperature in Celcius: 0
Temperature in Fahrenheit: 32
Temperature in Celcius: 65
Temperature in Fahrenheit: 149
Temperature in Celcius: 150
Temperature in Fahrenheit: 302
Temperature in Celcius: 20
Temperature in Fahrenheit: 68

Python Program to Convert Temperature in Celcius to Fahrenheit

Below is the Python program for Celcius to Fahrenheit conversion:

# Python program to convert temperature in Celcius to Fahrenheit
# Function to convert temperature in Celcius to Fahrenheit
def celciusToFahrenheit(num):
return ((num * 9.0 / 5.0) + 32.0)
num1 = 100.0
print("Temperature in Celcius:", num1)
print("Temperature in Fahrenheit:", celciusToFahrenheit(num1))
num2 = 0
print("Temperature in Celcius:", num2)
print("Temperature in Fahrenheit:", celciusToFahrenheit(num2))
num3 = 65.0
print("Temperature in Celcius:", num3)
print("Temperature in Fahrenheit:", celciusToFahrenheit(num3))
num4 = 150.0
print("Temperature in Celcius:", num4)
print("Temperature in Fahrenheit:", celciusToFahrenheit(num4))
num5 = 20.0
print("Temperature in Celcius:", num5)
print("Temperature in Fahrenheit:", celciusToFahrenheit(num5))

Output:

Temperature in Celcius: 100.0
Temperature in Fahrenheit: 212.0
Temperature in Celcius: 0
Temperature in Fahrenheit: 32.0
Temperature in Celcius: 65.0
Temperature in Fahrenheit: 149.0
Temperature in Celcius: 150.0
Temperature in Fahrenheit: 302.0
Temperature in Celcius: 20.0
Temperature in Fahrenheit: 68.0

Related: How to Complete the FizzBuzz Challenge in 5 Programming Languages

JavaScript Program to Convert Temperature in Celcius to Fahrenheit

Below is the JavaScript program for Celcius to Fahrenheit conversion:

// JavaScript program to convert temperature in Celcius to Fahrenheit
// Function to convert temperature in Celcius to Fahrenheit
function celciusToFahrenheit(num) {
return ((num * 9.0 / 5.0) + 32.0);
}

var num1 = 100.0;
document.write("Temperature in Celcius: " + num1 + "<br>");
document.write("Temperature in Fahrenheit: " + celciusToFahrenheit(num1) + "<br>");
var num2 = 0;
document.write("Temperature in Celcius: " + num2 + "<br>");
document.write("Temperature in Fahrenheit: " + celciusToFahrenheit(num2) + "<br>");
var num3 = 65.0;
document.write("Temperature in Celcius: " + num3 + "<br>");
document.write("Temperature in Fahrenheit: " + celciusToFahrenheit(num3) + "<br>");
var num4 = 150.0;
document.write("Temperature in Celcius: " + num4 + "<br>");
document.write("Temperature in Fahrenheit: " + celciusToFahrenheit(num4) + "<br>");
var num5 = 20.0;
document.write("Temperature in Celcius: " + num5 + "<br>");
document.write("Temperature in Fahrenheit: " + celciusToFahrenheit(num5) + "<br>");

Output:

Temperature in Celcius: 100
Temperature in Fahrenheit: 212
Temperature in Celcius: 0
Temperature in Fahrenheit: 32
Temperature in Celcius: 65
Temperature in Fahrenheit: 149
Temperature in Celcius: 150
Temperature in Fahrenheit: 302
Temperature in Celcius: 20
Temperature in Fahrenheit: 68

How to Convert Temperature in Fahrenheit to Celcius

You can convert the temperature in Fahrenheit to Celcius using the following formula:

 T(°C) = (T(°F) - 32) × 5/9

You need to subtract 32 from the °F temperature and then multiply it by 5/9. The result will be in °C.

Problem Statement

You're given a temperature num in °F, you need to convert it into °C. Example 1: Let num = 212. Therefore, the temperature in °C = (212 - 32) x 5/9 = 100 Thus, the output is 100. Example 2: Let num = 32. Therefore, the temperature in °C = (32 - 32) x 5/9 = 0 Thus, the output is 0. Related: How Do You Find the ASCII Value Of a Character?

C++ Program to Convert Temperature in Fahrenheit to Celcius

Below is the C++ program for Fahrenheit to Celcius conversion:

// C++ program to convert temperature in Fahrenheit to Celcius
#include <iostream>
using namespace std;
// Function to convert temperature in Fahrenheit to Celcius
float fahrenheitToCelcius(float num)
{
return ((num - 32.0) * 5.0 / 9.0);
}
int main()
{
float num1 = 212;
cout << "Temperature in Fahrenheit: " << num1 << endl;
cout << "Temperature in Celcius: " << fahrenheitToCelcius(num1) << endl;
float num2 = 32;
cout << "Temperature in Fahrenheit: " << num2 << endl;
cout << "Temperature in Celcius: " << fahrenheitToCelcius(num2) << endl;
float num3 = 149;
cout << "Temperature in Fahrenheit: " << num3 << endl;
cout << "Temperature in Celcius: " << fahrenheitToCelcius(num3) << endl;
float num4 = 302;
cout << "Temperature in Fahrenheit: " << num4 << endl;
cout << "Temperature in Celcius: " << fahrenheitToCelcius(num4) << endl;
float num5 = 68;
cout << "Temperature in Fahrenheit: " << num5 << endl;
cout << "Temperature in Celcius: " << fahrenheitToCelcius(num5) << endl;
return 0;
}

Output:

Temperature in Fahrenheit: 212
Temperature in Celcius: 100
Temperature in Fahrenheit: 32
Temperature in Celcius: 0
Temperature in Fahrenheit: 149
Temperature in Celcius: 65
Temperature in Fahrenheit: 302
Temperature in Celcius: 150
Temperature in Fahrenheit: 68
Temperature in Celcius: 20

Python Program to Convert Temperature in Fahrenheit to Celcius

Below is the Python program for Fahrenheit to Celcius conversion:

# Python program to convert temperature in Fahrenheit to Celcius
# Function to convert temperature in Fahrenheit to Celcius
def fahrenheitToCelcius(num):
return ((num - 32.0) * 5.0 / 9.0)
num1 = 212
print("Temperature in Fahrenheit:", num1)
print("Temperature in Celcius:", fahrenheitToCelcius(num1))
num2 = 32
print("Temperature in Fahrenheit:", num2)
print("Temperature in Celcius:", fahrenheitToCelcius(num2))
num3 = 149
print("Temperature in Fahrenheit:", num3)
print("Temperature in Celcius:", fahrenheitToCelcius(num3))
num4 = 302
print("Temperature in Fahrenheit:", num4)
print("Temperature in Celcius:", fahrenheitToCelcius(num4))
num5 = 68
print("Temperature in Fahrenheit:", num5)
print("Temperature in Celcius:", fahrenheitToCelcius(num5))

Output:

Temperature in Fahrenheit: 212
Temperature in Celcius: 100.0
Temperature in Fahrenheit: 32
Temperature in Celcius: 0.0
Temperature in Fahrenheit: 149
Temperature in Celcius: 65.0
Temperature in Fahrenheit: 302
Temperature in Celcius: 150.0
Temperature in Fahrenheit: 68
Temperature in Celcius: 20.0

Related: How to Find the LCM and GCD of Two Numbers in Multiple Languages

JavaScript Program to Convert Temperature in Fahrenheit to Celcius

Below is the JavaScript program for Fahrenheit to Celcius conversion:

// JavaScript program to convert temperature in Celcius to Fahrenheit
// Function to convert temperature in Celcius to Fahrenheit
function fahrenheitToCelcius(num) {
return ((num - 32.0) * 5.0 / 9.0);
}

var num1 = 212;
document.write("Temperature in Fahrenheit: " + num1 + "<br>");
document.write("Temperature in Celcius: " + fahrenheitToCelcius(num1) + "<br>");
var num2 = 32;
document.write("Temperature in Fahrenheit: " + num2 + "<br>");
document.write("Temperature in Celcius: " + fahrenheitToCelcius(num2) + "<br>");
var num3 = 149;
document.write("Temperature in Fahrenheit: " + num3 + "<br>");
document.write("Temperature in Celcius: " + fahrenheitToCelcius(num3) + "<br>");
var num4 = 302;
document.write("Temperature in Fahrenheit: " + num4 + "<br>");
document.write("Temperature in Celcius: " + fahrenheitToCelcius(num4) + "<br>");
var num5 = 68;
document.write("Temperature in Fahrenheit: " + num5 + "<br>");
document.write("Temperature in Celcius: " + fahrenheitToCelcius(num5) + "<br>");

Output:

Temperature in Fahrenheit: 212
Temperature in Celcius: 100
Temperature in Fahrenheit: 32
Temperature in Celcius: 0
Temperature in Fahrenheit: 149
Temperature in Celcius: 65
Temperature in Fahrenheit: 302
Temperature in Celcius: 150
Temperature in Fahrenheit: 68
Temperature in Celcius: 20

Converting Celsius to Fahrenheit Doesn’t Need to Be Difficult

So, there you have it—now you know how to convert Celsius to Fahrenheit—and vice versa. Knowing the two main temperature types is important, especially if you do any kind of work in both the US (or the small selection of other places that use Fahrenheit) and other countries.

The best way to learn to program is by developing projects. Developing projects help you to become a better programmer. If you're new to programming and looking for some beginner-level projects, you can try developing some projects like a chess game, calculator, digital clock, simple website, to-do list app, and so on.