Skip to content

Instantly share code, notes, and snippets.

@sauntimo
Created November 11, 2014 13:25
Show Gist options
  • Save sauntimo/a4f284385a51d47bea2a to your computer and use it in GitHub Desktop.
Save sauntimo/a4f284385a51d47bea2a to your computer and use it in GitHub Desktop.
#include <stdio.h>
/* print Fahrenheit-Celsius table
for fahr = 0, 20, ..., 300; floating point version */
main()
{
float fahr, celsius;
#define LOWER 0 /* lower limit of temperature table */
#define UPPER 300 /* upper limit of temperature table */
printf("\n\nFahrenheit to Celsius Conversion Table\n\n");
for(fahr = LOWER; fahr <= UPPER; fahr = fahr + 20)
printf("%3.0f %s %6.1f %s\n", fahr, "F is ", (5.0 / 9.0) * (fahr - 32.0), "C.");
printf("\n\nCelsius to Fahrenheit Conversion Table\n\n");
for(celsius = LOWER; celsius <= UPPER; celsius = celsius + 20)
printf("%3.0f %s %6.1f %s\n", celsius, "C is ", ((9.0 / 5.0) * celsius) + 32.0, "F.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment