blob: 2f8bf10121546c33e991653ca9004280ce710312 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/*
Exercise 1-4. Write a program to print the corresponding Celcius to Fahrenheit
table.
===
F = C(9/5)+32
*/
#include <stdio.h>
int main () {
float fahr, cels;
int lower = 0;
int upper = 300;
int step = 20;
puts("Celsius to Fahrenheit");
puts(" C F");
cels = lower;
while (cels <= upper) {
fahr = (cels * (9.0/5.0)) + 32;
printf("%3.0f %6.1f\n", cels, fahr);
cels += step;
}
}
|