The Convert the Temperature interview question is a basic mathematical problem. You are given a temperature in Celsius and must convert it into two other scales: Kelvin and Fahrenheit. The formulas are provided: Kelvin = Celsius + 273.15 and Fahrenheit = Celsius * 1.80 + 32.00. You return the results as an array or list.
While simple, companies like Microsoft and Meta use the Convert the Temperature coding problem as a sanity check or for very entry-level roles. It evaluates whether a candidate can follow basic specifications, handle floating-point numbers correctly, and return results in the requested format. It's often used to test familiarity with a new programming language's basic syntax.
This is a simple Math interview pattern. There are no complex loops or data structures required. You simply apply the formulas and store the results.
k = celsius + 273.15f = celsius * 1.8 + 32.0[k, f]Input: celsius = 36.50
36.50 + 273.15 = 309.6536.50 * 1.8 + 32.0 = 65.7 + 32.0 = 97.7
Output: [309.65, 97.70]Always double-check the precision requirements. If the output needs to be accurate to 5 decimal places, ensure you aren't using a data type that loses precision early on.