5.7.4. Procedures

Some functions only perform actions and do not return any useful results. I will call such functions procedures. Notice that a procedure is a special case of a function.

The return-type of a procedure is void. For example,

  void printHeading()
  {
    printf("Here is the input.\n");
  }
defines procedure printHeading, with no parameters. Notice that, because the return-type is void, there is no return statement. The procedure returns when it reaches the end of the body.

If you want to include an explicit return in a procedure, write

  return;
No result is indicated because a procedure does not have a result.


Using procedures

Use a procedure in a statement. For example,

  printHeading();
performs the body of printHeading.