1-4

ちょっとした復習。

[ERROR:15]% cat 1-4.c |c2utf && ./1-4     
#include <stdio.h>

/*
 * celsius=0,20,・・・300に対して、摂氏-華氏温度対応表を作成
 **/
main(){
        float fahr, celsius;
        int lower, upper, step;

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

        celsius = lower;
        printf("%8s %5s\n", "celsius", "fahr");
        while(celsius <= upper){
                fahr = (celsius / (5.0/9.0)) + 32.0;
                printf("%5.0f %8.1f\n", celsius, fahr );
                celsius += step;
        }
}

 celsius  fahr
    0     32.0
   20     68.0
   40    104.0
   60    140.0
   80    176.0
  100    212.0
  120    248.0
  140    284.0
  160    320.0
  180    356.0
  200    392.0
  220    428.0
  240    464.0
  260    500.0
  280    536.0
  300    572.0