1
0
mirror of https://github.com/krislamo/knrc.git synced 2025-09-11 08:29:30 +00:00

Exercise 1-15. Make temp. conversion function

This commit is contained in:
2021-11-23 00:52:13 -05:00
parent 984c019e14
commit 7825fcd167

View File

@@ -4,6 +4,8 @@
#define UPPER 300
#define STEP 20
float convert(int f);
/* print Fahrenheit-Celsius table */
int main()
{
@@ -11,5 +13,10 @@ int main()
printf("Fahrenheit\tCelsius\n=======================\n");
for (fahr = UPPER; fahr >= LOWER; fahr = fahr - STEP)
printf("%3d\t\t%7.1f\n", fahr, (5.0/9.0)*(fahr-32));
printf("%3d\t\t%7.1f\n", fahr, convert(fahr));
}
float convert(int fahr)
{
return (5.0/9.0)*(fahr-32);
}