exc/k&r/01-a-tutorial-introduction/01-15.c

23 lines
368 B
C

#include <stdio.h>
#define LOWER 0
#define UPPER 300
#define STEP 20
float cels_of_fahr(float fahr);
int main()
{
int fahr;
printf("%3c %6c\n", 'F', 'C');
for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP)
printf("%3d %6.1f\n", fahr, cels_of_fahr(fahr));
return 0;
}
float cels_of_fahr(float fahr)
{
return (5.0/9.0) * (fahr-32);
}