File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
2
* Exercise 1.15. Rewrite the temperature conversion program of Section 1.2 to
3
3
* use a function for conversion.
4
+ *
4
5
* By Faisal Saadatmand
5
6
*/
6
7
7
8
#include <stdio.h>
8
9
9
10
/* functions */
10
- float fahrToCelsius (float );
11
+ float toCelsius (float );
11
12
12
- float fahrToCelsius (float fahr )
13
+ float toCelsius (float f )
13
14
{
14
- float celsius ;
15
- celsius = (5.0 / 9.0 ) * (fahr - 32.0 );
16
- return celsius ;
15
+ return (5.0 / 9.0 ) * (f - 32.0 );
17
16
}
18
17
19
18
int main (void )
20
19
{
21
- float fahrToCelsius (float );
22
-
23
20
float fahr , celsius ;
24
21
float lower , upper , step ;
25
22
@@ -30,9 +27,10 @@ int main(void)
30
27
fahr = lower ;
31
28
printf ("Fahrenheit\tCelsius\n" );
32
29
while (fahr <= upper ) {
33
- celsius = fahrToCelsius (fahr );
30
+ celsius = toCelsius (fahr );
34
31
printf ("%10.0f\t%7.1f\n" , fahr , celsius );
35
32
fahr = fahr + step ;
36
33
}
34
+
37
35
return 0 ;
38
36
}
You can’t perform that action at this time.
0 commit comments