Next: About this document ...
Up: Subroutines
Previous: Functions vs. Subroutines

Checkoff

Within a subroutine, assignments to actual parameters (through dummy parameters) are often used to communicate results back to the point of call. This approach is especially useful when more than one result must be communicated, since a function can only return one.

For example, consider the quadratic formula, which is used to solve quadratic equations of the form

The two solutions of this equation are

and

whenever ``a'' is not zero and the discriminant (the part under the square root sign) is not negative.

We cannot write a function to solve a quadratic equation if we want to return both solutions. However, we can use a subroutine to accomplish the same thing. Take a look at ``quadratic.f'' (or view it directly).

Homework

There is no homework with this lesson.


Next: About this document ...
Up: Subroutines
Previous: Functions vs. Subroutines

Hamlet Project
hamlet@cs.utah.edu