1-5
for文を使ってみる
[5638]% gcc 1-5.c -o 1-5 -Wall 1-5.c:6: warning: return type defaults to `int' 1-5.c: In function `main': 1-5.c:17: warning: control reaches end of non-void function [5639]% cat 1-5.c | c2utf #include <stdio.h> /* * fahr=300,280・・・0に対して、華氏-摂氏温度対応表を作成 **/ main(){ float fahr; int lower, upper, step; lower = 0; upper = 300; step = 20; printf("%5s %8s\n", "fahr", "celsius"); for(fahr = upper;lower <= fahr;fahr = fahr - step) printf("%5.0f %8.1f\n", fahr,(5.0/9.0) * (fahr - 32.0)); } [5640]% ./1-5 fahr celsius 300 148.9 280 137.8 260 126.7 240 115.6 220 104.4 200 93.3 180 82.2 160 71.1 140 60.0 120 48.9 100 37.8 80 26.7 60 15.6 40 4.4 20 -6.7 0 -17.8