The C programming Language Second Editing
(xu bao wen)
1-3: ANSWER
#include <stdio.h>
#define LOWER 0
#define UPPER 300
#define STEP 20
int main(int argc, char const *argv[])
{
int fahr;
printf("***temerature meter***\n");
for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP) {
printf("%3d %6.1f\t\n", fahr ,(5.0/9.0)*(fahr - 32));
}
return 0;
}
1-4:Answer
#include <stdio.h>
#define LOWER -17.8
#define UPPER 148.9
#define STEP 11.1
int main(int argc, char const *argv[])
{
float celsius;
printf("celsius trans fahr temperature meter\n");
for (celsius = LOWER; celsius <= UPPER; celsius = celsius + STEP)
printf("%6.1f %6.0f\n", celsius, (32 + 9*celsius/5));
return 0;
}