summaryrefslogtreecommitdiffstats
path: root/1/3.c
blob: 42a0099484e0016a92c069b9c7c0fce3ab352bcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>

/* Prints a conversion table from fahrenheit to celsius */
int main(int argc, char *argv[]) {
  float fahr, celsius;
  int lower, upper, step;

  lower = 0;
  upper = 300;
  step = 20;
  fahr = lower;

  printf("fahrenheit\tcelsius\n");

  while (fahr <= upper) {
    celsius = (5.0 / 9.0) * (fahr - 32.0);
    printf("%10.0f\t%7.1f\n", fahr, celsius);
    fahr = fahr + step;
  }

  return 0;
}