Detailed Function Definition

Remember the form of the function:
<type> <function name> (<parameter list>)
{
  <data declarations>
  <executable statements>
}
Here's the actual implementation of the function:
////////////////////////////////////////////
//  Function: cube
//  Computes the cube of an integer
//
//  Input: an integer value
// Output: an integer representing the cube
//         of the input
//
int cube(int value)
{
	// local variable to hold the result
	int result;

	// do the calculation
	result = value * value * value;

	// return the result to the caller
	return result;
}
Previous page
Next page

Back to Lesson 5 Index
Back to Outline