A function is a statement that can return the result of its execution to its caller. When the function has a data type that is not void, the function is replaced by its returned value, which can then be assigned to a variable of a compatible type.
The returned value may be explicitly assigned to a variable or it may be implicitly used within a statement and discarded at the completion of the statement.
Consider theinchesToFeet()function declaration and definition:
#include <stdio.h>
double inchesToFeet( double );
int main( void )
{
double inches = 1024.0;
double feet = 0.0;
feet = inchesToFeet( inches );
printf( "%12.3g inches is equal to %12.3g feet\n" , inches , feet );
return 0;
}
// Given inches, convert this to feet
//
double inchesToFeet( double someInches)
{
double someFeet = someInches / 12.0;
return someFeet;
}
In this function, we focus on the assignment that occurs at the return...