![]()
Faculty Supervisor: Al Day
Some material derived from lessons authored by Prof. Martha Selby
HTML documentation by: Larry Genalo Jr.
Date Last Updated: 7/24/96
![]()
The use of functions has some of the following advantages:
General Form:
return-value-type Function_Name(argument list)
{
declarations
.
statements
.
variable=(a C expression for value to be returned);
return(variable);
}
/*Program to calculate surface area and volume for a rectangular box*/ #includedouble box_area(double length, double width, double height){ double area; area=2.0*(length*width + length*height+width*height); } double box_volume(double length, double width, double height){ double volume; volume=length*width*height return volume; } int main(void) { double length, width, height, area, volume; FILE *inp; inp=fopen("IN.DAT","r"); fscanf(inp, "%lf%lf%lf",&length,&width,&height); area=box_volume(length, width, height); volume=box_volume(length, width, height); printf("Volume=%f]include double box_area(double length, double width, double height){ double area; area=2.0*(length*width + length*height+width*height); } double box_volume(double length, double width, double height){ double volume; volume=length*width*height return volume; } int main(void) { double length, width, height, area, volume; FILE *inp; inp=fopen("IN.DAT","r"); fscanf(inp, "%lf%lf%lf",&length,&width,&height); area=box_volume(length, width, height); volume=box_volume(length, width, height); printf("Volume=%f\n, Area=%f\n", volume, area); return 0; }
![]()
General Form:
Void Function_Name (arguments received, *arguments returned) { declarations . statements . *variable_1=(a C expression for 1st value to be returned); *variable_2=(a C expression for 2nd value to be returned); }


