Path: blob/master/languages/cprogs/Ex_1.3_fahr2celheading.c
1240 views
/***1*2* Exercise 1-3. Modify the temperature conversion program,3* Fahrenheit to Celsius, to print a heading above the table.4*5* print Fahrenheit-Celsius table for fahr = 0, 20, ..., 300;6* floating-point version.7*8***/910#include<stdio.h>1112int main(void)13{14printf("A program print Fahrenheit-Celsius\n");1516float fahr, celsius;17int lower, upper, step;1819lower = 0;20upper = 300;21step = 20;2223fahr = lower;242526printf("Fahr\tCelsius\t \n");2728while(fahr <= upper)29{30celsius = (5.0/9.0) * (fahr - 32.0);31printf("%4.0f %10.1f\n", fahr, celsius);32fahr = fahr + step;33}3435return 0;36}373839