This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ithm, and implement the code. Name your program conversion.c and compile with: gcc conv_lib.o conversion.c Temperature Conversion
For some people (like Canadians) it is difficult to get used to using some US units of measurement. For example, they always have to convert temperature readings from ˚F to units that make much more sense, like ˚C. Consider a library, defined in “conv_lib.h” that has functions that performs conversions. Use the function FtoC() to print a conversion chart that displays the converted temperature over a specified range and interval. Writing Custom Functions
• In addition to functions which are defined in libraries, C allows you to write your own customized functions. • When you use a customized function, you must include the following in your program:
– Declare the function at the beginning (or include a custom header file where the function is defined) – Call the function in the main body of your program – Define the function Function Declaration
• Included in your header • Declares the output type and the input parameters for the function • Declaration format:
return-value-type function-name( parameter list ); • Examples:
– int cube( int x ); – float maxtest( float a, float b, float c ); – char primetest( int num ); Function Definition
• Function definition is done after the main body of your program...
View Full Document
- Summer '08