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 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 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 0s 5280KB
stdin
Standard input is empty
stdout
The temperature in Celsius is: 0.00
The temperature in Celsius is: 0.56
The temperature in Celsius is: 1.11
The temperature in Celsius is: 1.67
The temperature in Celsius is: 2.22
The temperature in Celsius is: 2.78
The temperature in Celsius is: 3.33
The temperature in Celsius is: 3.89
The temperature in Celsius is: 4.44
The temperature in Celsius is: 5.00
The temperature in Celsius is: 5.56
The temperature in Celsius is: 6.11
The temperature in Celsius is: 6.67
The temperature in Celsius is: 7.22
The temperature in Celsius is: 7.78
The temperature in Celsius is: 8.33
The temperature in Celsius is: 8.89
The temperature in Celsius is: 9.44
The temperature in Celsius is: 10.00
The temperature in Celsius is: 10.56
The temperature in Celsius is: 11.11
The temperature in Celsius is: 11.67
The temperature in Celsius is: 12.22
The temperature in Celsius is: 12.78
The temperature in Celsius is: 13.33
The temperature in Celsius is: 13.89
The temperature in Celsius is: 14.44
The temperature in Celsius is: 15.00
The temperature in Celsius is: 15.56
The temperature in Celsius is: 16.11
The temperature in Celsius is: 16.67
The temperature in Celsius is: 17.22
The temperature in Celsius is: 17.78
The temperature in Celsius is: 18.33
The temperature in Celsius is: 18.89
The temperature in Celsius is: 19.44
The temperature in Celsius is: 20.00
The temperature in Celsius is: 20.56
The temperature in Celsius is: 21.11
The temperature in Celsius is: 21.67
The temperature in Celsius is: 22.22
The temperature in Celsius is: 22.78
The temperature in Celsius is: 23.33
The temperature in Celsius is: 23.89
The temperature in Celsius is: 24.44
The temperature in Celsius is: 25.00
The temperature in Celsius is: 25.56
The temperature in Celsius is: 26.11
The temperature in Celsius is: 26.67
The temperature in Celsius is: 27.22
The temperature in Celsius is: 27.78
The temperature in Celsius is: 28.33
The temperature in Celsius is: 28.89
The temperature in Celsius is: 29.44
The temperature in Celsius is: 30.00
The temperature in Celsius is: 30.56
The temperature in Celsius is: 31.11
The temperature in Celsius is: 31.67
The temperature in Celsius is: 32.22
The temperature in Celsius is: 32.78
The temperature in Celsius is: 33.33
The temperature in Celsius is: 33.89
The temperature in Celsius is: 34.44
The temperature in Celsius is: 35.00
The temperature in Celsius is: 35.56
The temperature in Celsius is: 36.11
The temperature in Celsius is: 36.67
The temperature in Celsius is: 37.22
The temperature in Celsius is: 37.78
The temperature in Celsius is: 38.33
The temperature in Celsius is: 38.89
The temperature in Celsius is: 39.44
The temperature in Celsius is: 40.00
The temperature in Celsius is: 40.56
The temperature in Celsius is: 41.11
The temperature in Celsius is: 41.67
The temperature in Celsius is: 42.22
The temperature in Celsius is: 42.78
The temperature in Celsius is: 43.33
The temperature in Celsius is: 43.89
The temperature in Celsius is: 44.44
The temperature in Celsius is: 45.00
The temperature in Celsius is: 45.56
The temperature in Celsius is: 46.11
The temperature in Celsius is: 46.67
The temperature in Celsius is: 47.22
The temperature in Celsius is: 47.78
The temperature in Celsius is: 48.33
The temperature in Celsius is: 48.89
The temperature in Celsius is: 49.44
The temperature in Celsius is: 50.00
The temperature in Celsius is: 50.56
The temperature in Celsius is: 51.11
The temperature in Celsius is: 51.67
The temperature in Celsius is: 52.22
The temperature in Celsius is: 52.78
The temperature in Celsius is: 53.33
The temperature in Celsius is: 53.89
The temperature in Celsius is: 54.44
The temperature in Celsius is: 55.00
The temperature in Celsius is: 55.56
The temperature in Celsius is: 56.11
The temperature in Celsius is: 56.67
The temperature in Celsius is: 57.22
The temperature in Celsius is: 57.78
The temperature in Celsius is: 58.33
The temperature in Celsius is: 58.89
The temperature in Celsius is: 59.44
The temperature in Celsius is: 60.00
The temperature in Celsius is: 60.56
The temperature in Celsius is: 61.11
The temperature in Celsius is: 61.67
The temperature in Celsius is: 62.22
The temperature in Celsius is: 62.78
The temperature in Celsius is: 63.33
The temperature in Celsius is: 63.89
The temperature in Celsius is: 64.44
The temperature in Celsius is: 65.00
The temperature in Celsius is: 65.56
The temperature in Celsius is: 66.11
The temperature in Celsius is: 66.67
The temperature in Celsius is: 67.22
The temperature in Celsius is: 67.78
The temperature in Celsius is: 68.33
The temperature in Celsius is: 68.89
The temperature in Celsius is: 69.44
The temperature in Celsius is: 70.00
The temperature in Celsius is: 70.56
The temperature in Celsius is: 71.11
The temperature in Celsius is: 71.67
The temperature in Celsius is: 72.22
The temperature in Celsius is: 72.78
The temperature in Celsius is: 73.33
The temperature in Celsius is: 73.89
The temperature in Celsius is: 74.44
The temperature in Celsius is: 75.00
The temperature in Celsius is: 75.56
The temperature in Celsius is: 76.11
The temperature in Celsius is: 76.67
The temperature in Celsius is: 77.22
The temperature in Celsius is: 77.78
The temperature in Celsius is: 78.33
The temperature in Celsius is: 78.89
The temperature in Celsius is: 79.44
The temperature in Celsius is: 80.00
The temperature in Celsius is: 80.56
The temperature in Celsius is: 81.11
The temperature in Celsius is: 81.67
The temperature in Celsius is: 82.22
The temperature in Celsius is: 82.78
The temperature in Celsius is: 83.33
The temperature in Celsius is: 83.89
The temperature in Celsius is: 84.44
The temperature in Celsius is: 85.00
The temperature in Celsius is: 85.56
The temperature in Celsius is: 86.11
The temperature in Celsius is: 86.67
The temperature in Celsius is: 87.22
The temperature in Celsius is: 87.78
The temperature in Celsius is: 88.33
The temperature in Celsius is: 88.89
The temperature in Celsius is: 89.44
The temperature in Celsius is: 90.00
The temperature in Celsius is: 90.56
The temperature in Celsius is: 91.11
The temperature in Celsius is: 91.67
The temperature in Celsius is: 92.22
The temperature in Celsius is: 92.78
The temperature in Celsius is: 93.33
The temperature in Celsius is: 93.89
The temperature in Celsius is: 94.44
The temperature in Celsius is: 95.00
The temperature in Celsius is: 95.56
The temperature in Celsius is: 96.11
The temperature in Celsius is: 96.67
The temperature in Celsius is: 97.22
The temperature in Celsius is: 97.78
The temperature in Celsius is: 98.33
The temperature in Celsius is: 98.89
The temperature in Celsius is: 99.44
The temperature in Celsius is: 100.00
The temperature in Fahrenheit is: 32.0
The temperature in Fahrenheit is: 33.8
The temperature in Fahrenheit is: 35.6
The temperature in Fahrenheit is: 37.4
The temperature in Fahrenheit is: 39.2
The temperature in Fahrenheit is: 41.0
The temperature in Fahrenheit is: 42.8
The temperature in Fahrenheit is: 44.6
The temperature in Fahrenheit is: 46.4
The temperature in Fahrenheit is: 48.2
The temperature in Fahrenheit is: 50.0
The temperature in Fahrenheit is: 51.8
The temperature in Fahrenheit is: 53.6
The temperature in Fahrenheit is: 55.4
The temperature in Fahrenheit is: 57.2
The temperature in Fahrenheit is: 59.0
The temperature in Fahrenheit is: 60.8
The temperature in Fahrenheit is: 62.6
The temperature in Fahrenheit is: 64.4
The temperature in Fahrenheit is: 66.2
The temperature in Fahrenheit is: 68.0
The temperature in Fahrenheit is: 69.8
The temperature in Fahrenheit is: 71.6
The temperature in Fahrenheit is: 73.4
The temperature in Fahrenheit is: 75.2
The temperature in Fahrenheit is: 77.0
The temperature in Fahrenheit is: 78.8
The temperature in Fahrenheit is: 80.6
The temperature in Fahrenheit is: 82.4
The temperature in Fahrenheit is: 84.2
The temperature in Fahrenheit is: 86.0
The temperature in Fahrenheit is: 87.8
The temperature in Fahrenheit is: 89.6
The temperature in Fahrenheit is: 91.4
The temperature in Fahrenheit is: 93.2
The temperature in Fahrenheit is: 95.0
The temperature in Fahrenheit is: 96.8
The temperature in Fahrenheit is: 98.6
The temperature in Fahrenheit is: 100.4
The temperature in Fahrenheit is: 102.2
The temperature in Fahrenheit is: 104.0
The temperature in Fahrenheit is: 105.8
The temperature in Fahrenheit is: 107.6
The temperature in Fahrenheit is: 109.4
The temperature in Fahrenheit is: 111.2
The temperature in Fahrenheit is: 113.0
The temperature in Fahrenheit is: 114.8
The temperature in Fahrenheit is: 116.6
The temperature in Fahrenheit is: 118.4
The temperature in Fahrenheit is: 120.2
The temperature in Fahrenheit is: 122.0
The temperature in Fahrenheit is: 123.8
The temperature in Fahrenheit is: 125.6
The temperature in Fahrenheit is: 127.4
The temperature in Fahrenheit is: 129.2
The temperature in Fahrenheit is: 131.0
The temperature in Fahrenheit is: 132.8
The temperature in Fahrenheit is: 134.6
The temperature in Fahrenheit is: 136.4
The temperature in Fahrenheit is: 138.2
The temperature in Fahrenheit is: 140.0
The temperature in Fahrenheit is: 141.8
The temperature in Fahrenheit is: 143.6
The temperature in Fahrenheit is: 145.4
The temperature in Fahrenheit is: 147.2
The temperature in Fahrenheit is: 149.0
The temperature in Fahrenheit is: 150.8
The temperature in Fahrenheit is: 152.6
The temperature in Fahrenheit is: 154.4
The temperature in Fahrenheit is: 156.2
The temperature in Fahrenheit is: 158.0
The temperature in Fahrenheit is: 159.8
The temperature in Fahrenheit is: 161.6
The temperature in Fahrenheit is: 163.4
The temperature in Fahrenheit is: 165.2
The temperature in Fahrenheit is: 167.0
The temperature in Fahrenheit is: 168.8
The temperature in Fahrenheit is: 170.6
The temperature in Fahrenheit is: 172.4
The temperature in Fahrenheit is: 174.2
The temperature in Fahrenheit is: 176.0
The temperature in Fahrenheit is: 177.8
The temperature in Fahrenheit is: 179.6
The temperature in Fahrenheit is: 181.4
The temperature in Fahrenheit is: 183.2
The temperature in Fahrenheit is: 185.0
The temperature in Fahrenheit is: 186.8
The temperature in Fahrenheit is: 188.6
The temperature in Fahrenheit is: 190.4
The temperature in Fahrenheit is: 192.2
The temperature in Fahrenheit is: 194.0
The temperature in Fahrenheit is: 195.8
The temperature in Fahrenheit is: 197.6
The temperature in Fahrenheit is: 199.4
The temperature in Fahrenheit is: 201.2
The temperature in Fahrenheit is: 203.0
The temperature in Fahrenheit is: 204.8
The temperature in Fahrenheit is: 206.6
The temperature in Fahrenheit is: 208.4
The temperature in Fahrenheit is: 210.2
The temperature in Fahrenheit is: 212.0