Master C++

Weather widget

Weather widget

A weather site stores every temperature in degrees Celsius, because that is what its sensors report. Some of its readers want degrees Fahrenheit instead, so the widget on the page calls your function once per reading.

Write toFahrenheit, which takes a temperature in degrees Celsius and returns the same temperature in degrees Fahrenheit. Multiply by nine, divide by five, and add thirty two.

Worked example

Input:  celsius = 20
20 * 9 = 180,  180 / 5 = 36,  36 + 32 = 68
Output: 68

Input:  celsius = 37.5
Output: 99.5

Constraints

  • celsius is between -100 and 1000, and may have a decimal part.
  • The answer may have a decimal part, and may be negative.
  • Answers are accepted if they are close enough, since these are decimals rather than whole numbers.
Code

Run your code to see how it does on the examples. Submit also runs the hidden cases.