Answers to questions on functions

  1. What is another name for a function which does not return a value?
    They are often called procedures. In languages like Pascal, the name procedure is explicitly used to declare them. Algol 60 had procedures and, when a value was returned, type procedures.

  2. Why is it good programming practice to use functions?
    It removes unnecessary detail from the main program and from function bodies. This makes it easier to follow the meaning of code. Meaningful names should always be used to help in this.

    Functions may also be re-usable in other programs where you want to do the same thing. C programmers often create libraries of re-usable functions, like stdio.h.

Back to the questions.


Back to notes on functions