Lesson goal: Using functions to convert temperatures

Previous: Returning values | Home | Next: Finding the Greatest Common Divisor (GCD)

Quick question: you are in London, England and it's $32^\circ$C outside. Is it hot or cold?

In the last lesson you learned how to return a value to a calling statement from within a function. Let's use such functions to convert between the Fahrenheit and Celsius temperature scales.

We'll use the standard formulas to convert between these two scales, which are $F=\frac{9}{5}C+32$ and $C=\frac{5}{9}(F-32)$.

Now you try. Program in the correct conversion formula into the parenthesis of the return statement.

Type your code here:


See your results here: