mirror of
https://github.com/krislamo/knrc.git
synced 2025-01-05 19:10:36 +00:00
Exercise 1-15. Make temp. conversion function
This commit is contained in:
parent
984c019e14
commit
7825fcd167
@ -4,6 +4,8 @@
|
||||
#define UPPER 300
|
||||
#define STEP 20
|
||||
|
||||
float convert(int f);
|
||||
|
||||
/* print Fahrenheit-Celsius table */
|
||||
int main()
|
||||
{
|
||||
@ -11,5 +13,10 @@ int main()
|
||||
|
||||
printf("Fahrenheit\tCelsius\n=======================\n");
|
||||
for (fahr = UPPER; fahr >= LOWER; fahr = fahr - STEP)
|
||||
printf("%3d\t\t%7.1f\n", fahr, (5.0/9.0)*(fahr-32));
|
||||
printf("%3d\t\t%7.1f\n", fahr, convert(fahr));
|
||||
}
|
||||
|
||||
float convert(int fahr)
|
||||
{
|
||||
return (5.0/9.0)*(fahr-32);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user