Skip to content

Commit f788e62

Browse files
committed
rename function
1 parent 5eb61d4 commit f788e62

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

chapter01/1-15.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
/*
22
* Exercise 1.15. Rewrite the temperature conversion program of Section 1.2 to
33
* use a function for conversion.
4+
*
45
* By Faisal Saadatmand
56
*/
67

78
#include <stdio.h>
89

910
/* functions */
10-
float fahrToCelsius(float);
11+
float toCelsius(float);
1112

12-
float fahrToCelsius(float fahr)
13+
float toCelsius(float f)
1314
{
14-
float celsius;
15-
celsius = (5.0 / 9.0) * (fahr-32.0);
16-
return celsius;
15+
return (5.0 / 9.0) * (f - 32.0);
1716
}
1817

1918
int main(void)
2019
{
21-
float fahrToCelsius(float);
22-
2320
float fahr, celsius;
2421
float lower, upper, step;
2522

@@ -30,9 +27,10 @@ int main(void)
3027
fahr = lower;
3128
printf("Fahrenheit\tCelsius\n");
3229
while (fahr <= upper) {
33-
celsius = fahrToCelsius(fahr);
30+
celsius = toCelsius(fahr);
3431
printf("%10.0f\t%7.1f\n", fahr, celsius);
3532
fahr = fahr + step;
3633
}
34+
3735
return 0;
3836
}

0 commit comments

Comments
 (0)