fork download
  1. //********************************************************
  2. //
  3. // C Midterm - Question 7
  4. //
  5. // Name: Maya Mahin
  6. //
  7. // Class: C Programming, Spring 2025
  8. //
  9. // Date: March 23, 2025
  10. //
  11. // Description: Program which facilitates the conversion of fahrenheit to
  12. // celsius temperatures and vice versa
  13. //
  14. //********************************************************
  15.  
  16. #include <stdio.h>
  17.  
  18. float toCelsius(float fahrenheitTemp);
  19. float toFahrenheit(float celsiusTemp);
  20.  
  21. int main(void) {
  22. float celsiusRetVal=toCelsius(32);
  23. printf("The temperature in Celsius is: %.1f\n", celsiusRetVal);
  24.  
  25. float fahrenheitRetVal=toFahrenheit(0);
  26. printf("The temperature in Fahrenheit is: %.1f\n", fahrenheitRetVal);
  27.  
  28. return 0;
  29. }
  30.  
  31. //**************************************************************
  32. // Function: toCelsius
  33. //
  34. // Purpose: Receives a temperature in fahrenheit, converts it
  35. // to Celsius and returns the converted value
  36. //
  37. // Parameters:
  38. //
  39. // temp - input temperature in fahrenheit
  40. //
  41. // Returns: temp_convert - input temperature in celsius
  42. //
  43. //**************************************************************
  44. float toCelsius(float fahrenheitTemp){
  45. float celsiusTemp=(fahrenheitTemp - 32) * 5/9;
  46. return celsiusTemp;
  47. }
  48. //**************************************************************
  49. // Function: toFahrenheit
  50. //
  51. // Purpose: Receives a temperature in celsius, converts it
  52. // to Fahrenheit and returns the converted value
  53. //
  54. // Parameters:
  55. //
  56. // temp - input temperature in celsius
  57. //
  58. // Returns: temp_convert - input temperature in fahrenheit
  59. //
  60. //**************************************************************
  61. float toFahrenheit(float celsiusTemp){
  62. float fahrenheitTemp=(celsiusTemp - 32) * 5/9;
  63. return fahrenheitTemp;
  64. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
The temperature in Celsius is: 0.0
The temperature in Fahrenheit is: -17.8