fork download
  1. // Add file header here
  2. #include <stdio.h>
  3.  
  4. // function prototypes
  5. float toCelsius (int theFahrenheitTemp);
  6. float toFahrenheit (int theCelsiusTemp);
  7.  
  8. int main ()
  9. {
  10. int i; // loop index
  11. float temp;
  12.  
  13. // create some loop to print Celsius to Fahrenheit
  14. for (i = 0 ; i <= 100 ; ++i){
  15. temp = toFahrenheit (i);
  16. printf("\n %d %3.1f", i, temp);
  17.  
  18. }
  19.  
  20. // call and print results from each of the functions
  21.  
  22. // end loop 1
  23.  
  24. // create some loop to print Fahrenheit to Celsius
  25.  
  26. // call and print results from each of the functions
  27.  
  28. // end loop 2
  29.  
  30. }
  31.  
  32. // add your two function definitions here
  33.  
  34. // add function header comments
  35. float toCelsius (int theFahrenheitTemp)
  36. {
  37. //Deduct 32, then multiply by 5, then divide by 9
  38. float theCelsiusTemp;
  39. theCelsiusTemp = (theFahrenheitTemp - 32) * 5 / 9;
  40. return theCelsiusTemp;
  41. }
  42.  
  43. // add function header comments
  44. float toFahrenheit (int theCelsiusTemp)
  45. {
  46. //Divide by 5, then multiply by 9, then add 32
  47. float theFahrenheitTemp;
  48. theFahrenheitTemp = theCelsiusTemp / 5.0 * 9.0 + 32;
  49. return theFahrenheitTemp;
  50.  
  51. }
  52.  
  53.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
 0  32.0
 1  33.8
 2  35.6
 3  37.4
 4  39.2
 5  41.0
 6  42.8
 7  44.6
 8  46.4
 9  48.2
 10  50.0
 11  51.8
 12  53.6
 13  55.4
 14  57.2
 15  59.0
 16  60.8
 17  62.6
 18  64.4
 19  66.2
 20  68.0
 21  69.8
 22  71.6
 23  73.4
 24  75.2
 25  77.0
 26  78.8
 27  80.6
 28  82.4
 29  84.2
 30  86.0
 31  87.8
 32  89.6
 33  91.4
 34  93.2
 35  95.0
 36  96.8
 37  98.6
 38  100.4
 39  102.2
 40  104.0
 41  105.8
 42  107.6
 43  109.4
 44  111.2
 45  113.0
 46  114.8
 47  116.6
 48  118.4
 49  120.2
 50  122.0
 51  123.8
 52  125.6
 53  127.4
 54  129.2
 55  131.0
 56  132.8
 57  134.6
 58  136.4
 59  138.2
 60  140.0
 61  141.8
 62  143.6
 63  145.4
 64  147.2
 65  149.0
 66  150.8
 67  152.6
 68  154.4
 69  156.2
 70  158.0
 71  159.8
 72  161.6
 73  163.4
 74  165.2
 75  167.0
 76  168.8
 77  170.6
 78  172.4
 79  174.2
 80  176.0
 81  177.8
 82  179.6
 83  181.4
 84  183.2
 85  185.0
 86  186.8
 87  188.6
 88  190.4
 89  192.2
 90  194.0
 91  195.8
 92  197.6
 93  199.4
 94  201.2
 95  203.0
 96  204.8
 97  206.6
 98  208.4
 99  210.2
 100  212.0