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. for (int i=32; i<213; i++) {
  23. float celsiusRetVal=toCelsius(i);
  24. printf("The temperature in Celsius for",i, "is: %.2f\n", celsiusRetVal);
  25. }
  26.  
  27. for (int i=0; i<101; i++) {
  28. float fahrenheitRetVal=toFahrenheit(i);
  29. printf("The temperature in Fahrenheit for",i,"is: %.1f\n", fahrenheitRetVal);
  30. }
  31.  
  32. return 0;
  33. }
  34.  
  35. //**************************************************************
  36. // Function: toCelsius
  37. //
  38. // Purpose: Receives a temperature in fahrenheit, converts it
  39. // to Celsius and returns the converted value
  40. //
  41. // Parameters:
  42. //
  43. // temp - input temperature in fahrenheit
  44. //
  45. // Returns: temp_convert - input temperature in celsius
  46. //
  47. //**************************************************************
  48. float toCelsius(float fahrenheitTemp){
  49. float celsiusTemp=(fahrenheitTemp - 32) * 5/9;
  50. return celsiusTemp;
  51. }
  52. //**************************************************************
  53. // Function: toFahrenheit
  54. //
  55. // Purpose: Receives a temperature in celsius, converts it
  56. // to Fahrenheit and returns the converted value
  57. //
  58. // Parameters:
  59. //
  60. // temp - input temperature in celsius
  61. //
  62. // Returns: temp_convert - input temperature in fahrenheit
  63. //
  64. //**************************************************************
  65. float toFahrenheit(float celsiusTemp){
  66. float fahrenheitTemp=(celsiusTemp * 9/5) + 32;
  67. return fahrenheitTemp;
  68. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
The temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Celsius forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit forThe temperature in Fahrenheit for