69,371
社区成员
发帖
与我相关
我的任务
分享
/*
* File:c2ftable.c
*---------------
*This program illustrates the use of runctions by generating
*a table of Celsius to Fahrenheit convesions.
*/
# include <stdio.h>
//# include "genlib.h"
/*
*constants
*---------------
*LowerLimit -- Starting value for temperature table
*UpperLimit -- Final value for temperature table
*StepSize --Step size between table entries
*/
#define LowerLimit 0
#define UpperLimit 100
#define StepSize 5
/* Function Prototypes*/
double CelsiusToFahrenheit (double c);
/* Main program */
int main( )
{
int c;
printf ("Celsius to Fahrenheit table.\n");
printf ("C F\n");
for (c=LowerLimit; c <=UpperLimit; c+=StepSize)
{
printf ("%3d %4f\n" , c, CelsiusToFahrenheit (c));
}
system("pause");
return 0;
}
/*
* Function:CelsiusToFahrenheit
* Usage: f=CelsiusToFahrenheit(c);
*----------------------------------------
* This function returns Fahrenheit equivalent of the Celsius
* temperature C.
*/
double CelsiusToFahrenheit(double c)
{
return ( (9.0 / 5.0) * c + 32 ) ;
}