The best way to learn C is by doing. In this challenge, you will combine everything you've learned—**Return Types**, **Parameters**, and **Function Declarations**—to build a practical utility program.
Your task is to create a program that converts temperatures between Celsius and Fahrenheit. This is a classic exercise because it requires mathematical logic and proper function structure.
[Image of Celsius to Fahrenheit conversion formula diagram]To complete this challenge successfully, your code must meet the following criteria:
main).toFahrenheit(float celsius) — This should take Celsius as an argument and return the Fahrenheit value.toCelsius(float fahrenheit) — This should take Fahrenheit as an argument and return the Celsius value.main(), ask the user to input a temperature and then display the converted results.You will need these formulas to write your logic:
(Celsius * 9/5) + 32(Fahrenheit - 32) * 5/9Try to write it yourself first! If you get stuck, here is a professional structure you can follow:
If you found the basic challenge too easy, try adding these features:
switch or if...else inside main to let the user choose which conversion they want to perform.9.0 / 5.0 instead of 9 / 5. In C, 9 / 5 uses integer division and results in 1, whereas 9.0 / 5.0 ensures you get the precise floating-point value of 1.8.