Convert Celsius to Fahrenheit
Convert a temperature from degrees Celsius to degrees Fahrenheit.
Course progress
Problem 23 of 100
Example → approach → runnable solution
Worked example
See the problem in action
Trace a concrete input through to the verified result.
Example input
celsius = 25
Expected output
77
What is happening?
Apply Fahrenheit = Celsius x 9 / 5 + 32: 25 x 9 / 5 + 32 = 77.
Solution strategy
Build the right mental model
Multiply the Celsius value by 9/5 using floating-point division, then add 32.
Core concepts
arithmetic · methods
Complexity
Time O(1), space O(1).
Runnable solution
Learn from working code
Compare languages, copy the code, or open it in the compiler.
Complete C# solution for celsius-to-fahrenheit
using System;
class Program
{
static double CelsiusToFahrenheit(double celsius)
{
return celsius * 9.0 / 5.0 + 32.0;
}
static void Main()
{
Console.WriteLine(CelsiusToFahrenheit(25));
}
}Knowledge check
Questions students often ask
What is the main idea behind convert celsius to fahrenheit?
Multiply the Celsius value by 9/5 using floating-point division, then add 32.
What is the time and space complexity of this solution?
Time O(1), space O(1).
Do all language tabs solve the same problem?
Yes. Every program uses the same example and produces the verified output shown on this page. The syntax and a few language-specific data structures differ.