Problem
Convert a temperature in degrees Celsius to degrees Fahrenheit using F = C × 9 / 5 + 32.
Implement celsius_to_fahrenheit(celsius).
Input
celsius: The temperature in degrees Celsius.
Output
Return the temperature in degrees Fahrenheit (a decimal number).
Constraints
-273.15 ≤ celsius ≤ 10,000
Examples
Input:
celsius = 100.0
Expected output:
expected = 212.0
Input:
double celsius = 100.0;
Expected output:
double expected = 212.0;
Input:
double celsius = 100.0;
Expected output:
double expected = 212.0;
Explanation
100 × 9 / 5 + 32 = 212, the boiling point of water.
Input:
celsius = -40.0
Expected output:
expected = -40.0
Input:
double celsius = -40.0;
Expected output:
double expected = -40.0;
Input:
double celsius = -40.0;
Expected output:
double expected = -40.0;
Explanation
-40 × 9 / 5 + 32 = -40: both scales meet at -40.
How to approach it
Try on your own first, then open one hint at a time.
Hint 1
This is a direct unit conversion from one linear scale to another.
Hint 2
Apply the given formula carefully, especially the order of multiplication and division.
Hint 3
Keep the result as a decimal value, since many inputs do not convert to integers exactly.
Expected complexity
O(1) time, O(1) extra space
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.