Returning From Functions

 

A function stops executing and returns to the calling program (function) in any one of several ways:

 

Multiple return statements are permitted (although some purists argue that this is unstructured).

 

The return type of a returned value should match the prototype. However, the rules for type conversion also apply to function return values. The compiler promotes or demotes  returned numeric values to accommodate the expressions in which your program uses the function calls.

 

Returned values may be ignored. In other words, just because a function returns a value, does not mean that the function may not be called as a stand alone statement. For example:

 

Int area(int width, int length)

{

          return width * length;

}

 

int main()

{

          area( 6, 13);

          return 0;

}

 

The example is meaningless, but it will compile and run. The point is, you can ignore the return value.