What was the temperature again?
We are going to see how well we’ve understood the “if” and “else” conditionals, you know, those pesky words from fifth grade Grammar:
First up we have the code. Notice that there is a void type function before the main function. This was used by me in order to see if I knew how to correctly use those, and it turned out well, but the code can do without a void type function, having the “if” and “else” conditionals inside the main funciton.
As usual, we compile in Cygwin to check for any mistakes and happily find out there are none, giving the program the value 289 as Fahrenheit temperature.
It does work! We get the conversion from Fahrenheit to Celsius and a message indicating that water reaches its boiling point at this temperature. Then we try with a lower value and get a message informing us that this is too low for water to become a gas.
WSQ05 by Alan S. Olalla is licensed under a Creative Commons Attribution 4.0 International License.