Last active
July 21, 2019 03:25
-
-
Save airicbear/9a821133faefa2c68a96e3785c140228 to your computer and use it in GitHub Desktop.
Fahrenheit/Celsius table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define LOWER 0 /* lower limit of temp. table (in Fahrenheit) */ | |
#define UPPER 300 /* upper limit */ | |
#define STEP 20 /* step size */ | |
double fahrenheitToCelsius(int fahr) { | |
return (5.0 / 9.0) * (fahr - 32.0); | |
} | |
void printConversion(int fahr) { | |
printf("%3d \t %6.1f\n", fahr, fahrenheitToCelsius(fahr)); | |
} | |
void printConversions(int fahr) { | |
if (fahr > UPPER) { | |
return; | |
} else { | |
printConversion(fahr); | |
return printConversions(fahr + STEP); | |
} | |
} | |
int main(void) { | |
printConversions(LOWER); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 -17.8 | |
20 -6.7 | |
40 4.4 | |
60 15.6 | |
80 26.7 | |
100 37.8 | |
120 48.9 | |
140 60.0 | |
160 71.1 | |
180 82.2 | |
200 93.3 | |
220 104.4 | |
240 115.6 | |
260 126.7 | |
280 137.8 | |
300 148.9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment