Next: Homework assignment, 100 points
Up: Local Variables
Previous: The Syntax
Contents
Local variables are very similar to parameters passed by value. Both
have storage can change their values as the program executes. The only
differences between a local variable and a parameter passed by value are
the syntax of their definition and that a parameter passed by value has
an initial value determined by the caller of the subroutine. A local
variable does not have any initial value. As a result, it is
important for a programmer to initialize a local variable before
using its value.
Just like parameters, local variables are ``destroyed'' when a subroutine
completes. This means the value of a local variable is not preserved
across invocations.
Tak Auyeung
2003-12-03