#include <stdio.h>
int main(){
int height1, height2, i, d;
double weight;
printf("何cmから:"); scanf("%d", &height1);
printf("何cmまで:"); scanf("%d", &height2);
printf("何cmごと:"); scanf("%d", &d);
for (i = height1; i <= height2; i = i + d){
weight = (i - 100) * 0.9;
printf("%dcm %fkg\n", i, weight);
}
return 0;
}
演習4-15の本文に掲載されている実行例について、「155cmから190cm」と入力しているにもかかわらず、「155cm 49.50kg 160cm 54.00kg」としか書かれていないのは誤植なのでしょうか。
返信削除for (i = height1; i <= height2; i = i + d){
返信削除weight = (i - 100) * 0.9;
printf("%dcm %.2fkg\n", i, weight);
}
%.2fkg\n