/*
 * K&R C Programming language
 * -----------------------------------------------------------
 * Exercise 1-15.
 *
 * Rewrite the temperature conversion program of Section 1.2
 * to use a function for conversion
 *
 */

#include <stdio.h>

#define LOWER   0
#define UPPER   300
#define STEP    20

float celsius(int fahr);

int
main()
{
    int fahr;

    for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP)
        printf("%3d %6.1f\n", fahr, celsius(fahr));
    return 0;
}

/* celsius: return celsius equivalent of given Fahrenheit degree */
float
celsius(int fahr)
{
    return (5.0/9.0) * (fahr-32);
}
