fork download
  1. #include <stdio.h>
  2.  
  3. // add function prototypes
  4. float toCelsius (float theFahrenheitTemp);
  5. float toFahrenheit (float theCelsiusTemp);
  6.  
  7. int main ()
  8. {
  9.  
  10. float celsius;
  11. float fahrenheit;
  12.  
  13. printf ("\n Celsius to Fahrenheit \n");
  14. printf("----------------------\n");
  15. // create some loop to print
  16. for (int i = 0; i <= 100; i++)
  17. {
  18. printf ("%4d %12.1f \n", i, toFahrenheit(i));
  19. }
  20.  
  21. printf ("\n Fahrenheit to Celsius \n");
  22. printf("--------------------- \n");
  23. // create some loop to print
  24. for (int i = 32; i <= 212; i++)
  25. {
  26. printf ("%4d %12.1f \n", i, toCelsius(i));
  27. }
  28.  
  29. // call and print results from each of the functions
  30.  
  31.  
  32. }
  33.  
  34. // add your two function definitions here
  35.  
  36. // add function header comments
  37. float toCelsius (float theFahrenheitTemp)
  38. {
  39. float celsius; //celcius tempurture
  40.  
  41. celsius = (theFahrenheitTemp - 32) * 5 / 9;
  42.  
  43. return celsius;
  44.  
  45. } //toCelsius
  46.  
  47. // add function header comments
  48.  
  49. float toFahrenheit (float theCelsiusTemp)
  50. {
  51. float fahrenheit; //fahrenheit tempurture
  52.  
  53. fahrenheit = ((theCelsiusTemp / 5) * 9) + 32;
  54.  
  55. return fahrenheit;
  56.  
  57. } //toFahrenheit
  58.  
  59.  
  60.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
 Celsius to Fahrenheit 
----------------------
   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 

 Fahrenheit to Celsius 
--------------------- 
  32          0.0 
  33          0.6 
  34          1.1 
  35          1.7 
  36          2.2 
  37          2.8 
  38          3.3 
  39          3.9 
  40          4.4 
  41          5.0 
  42          5.6 
  43          6.1 
  44          6.7 
  45          7.2 
  46          7.8 
  47          8.3 
  48          8.9 
  49          9.4 
  50         10.0 
  51         10.6 
  52         11.1 
  53         11.7 
  54         12.2 
  55         12.8 
  56         13.3 
  57         13.9 
  58         14.4 
  59         15.0 
  60         15.6 
  61         16.1 
  62         16.7 
  63         17.2 
  64         17.8 
  65         18.3 
  66         18.9 
  67         19.4 
  68         20.0 
  69         20.6 
  70         21.1 
  71         21.7 
  72         22.2 
  73         22.8 
  74         23.3 
  75         23.9 
  76         24.4 
  77         25.0 
  78         25.6 
  79         26.1 
  80         26.7 
  81         27.2 
  82         27.8 
  83         28.3 
  84         28.9 
  85         29.4 
  86         30.0 
  87         30.6 
  88         31.1 
  89         31.7 
  90         32.2 
  91         32.8 
  92         33.3 
  93         33.9 
  94         34.4 
  95         35.0 
  96         35.6 
  97         36.1 
  98         36.7 
  99         37.2 
 100         37.8 
 101         38.3 
 102         38.9 
 103         39.4 
 104         40.0 
 105         40.6 
 106         41.1 
 107         41.7 
 108         42.2 
 109         42.8 
 110         43.3 
 111         43.9 
 112         44.4 
 113         45.0 
 114         45.6 
 115         46.1 
 116         46.7 
 117         47.2 
 118         47.8 
 119         48.3 
 120         48.9 
 121         49.4 
 122         50.0 
 123         50.6 
 124         51.1 
 125         51.7 
 126         52.2 
 127         52.8 
 128         53.3 
 129         53.9 
 130         54.4 
 131         55.0 
 132         55.6 
 133         56.1 
 134         56.7 
 135         57.2 
 136         57.8 
 137         58.3 
 138         58.9 
 139         59.4 
 140         60.0 
 141         60.6 
 142         61.1 
 143         61.7 
 144         62.2 
 145         62.8 
 146         63.3 
 147         63.9 
 148         64.4 
 149         65.0 
 150         65.6 
 151         66.1 
 152         66.7 
 153         67.2 
 154         67.8 
 155         68.3 
 156         68.9 
 157         69.4 
 158         70.0 
 159         70.6 
 160         71.1 
 161         71.7 
 162         72.2 
 163         72.8 
 164         73.3 
 165         73.9 
 166         74.4 
 167         75.0 
 168         75.6 
 169         76.1 
 170         76.7 
 171         77.2 
 172         77.8 
 173         78.3 
 174         78.9 
 175         79.4 
 176         80.0 
 177         80.6 
 178         81.1 
 179         81.7 
 180         82.2 
 181         82.8 
 182         83.3 
 183         83.9 
 184         84.4 
 185         85.0 
 186         85.6 
 187         86.1 
 188         86.7 
 189         87.2 
 190         87.8 
 191         88.3 
 192         88.9 
 193         89.4 
 194         90.0 
 195         90.6 
 196         91.1 
 197         91.7 
 198         92.2 
 199         92.8 
 200         93.3 
 201         93.9 
 202         94.4 
 203         95.0 
 204         95.6 
 205         96.1 
 206         96.7 
 207         97.2 
 208         97.8 
 209         98.3 
 210         98.9 
 211         99.4 
 212        100.0