What is a Function?

So what exactly is a function? You probably have an intuitive notion of what a function is, but it's hard to write down a single definition because different people use the word ``function'' to describe different (but related) things. For example, if you were a mathematician you might say:

``A function is a certain kind of mapping from one set of values to another set of values.''

And a person who uses Maple might say:

``A function is something that takes one or more values, performs a computation with those values, and produces a result.''

In this lesson, however, we're most interested in what a C programmer would say:

``A function is a component of a program. A function takes a list of argument values, performs a computation with those values, and returns a single result.''

The last definition tells you that functions are things that can be used to build programs. You've already used Maple functions to build Maple; today you'll learn how to do the same thing in C.


Eric N. Eide
Hamlet Project
Department of Computer Science
University of Utah