Skip to content

Commit 2f77d4c

Browse files
author
Robert Fox
committed
changes conversion to float arithmetic, added column headers
1 parent 278cdb4 commit 2f77d4c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
56 Bytes
Binary file not shown.

Ch1_Tutorial_Introduction/fahr_to_cel.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
int main()
66
{
7-
int fahr, cels;
7+
float fahr, cels;
88
int lower, upper, step;
99

1010
lower = 0;
@@ -13,9 +13,10 @@ int main()
1313

1414
fahr = lower;
1515

16+
printf("Deg F\t Deg C\n");
1617
while (fahr <= upper){
1718
cels=5*(fahr-32)/9;
18-
printf("%d\t%d\n",fahr,cels);
19+
printf("%5.0f\t%6.1f\n",fahr,cels);
1920
fahr = fahr+ step;
2021
}
2122

0 commit comments

Comments
 (0)