Value Parameters
In the previous programs, when variables are passed to procedures,
the procedures work with a copy of the original variable.
The value of the original variables which are passed to the
procedure are not changed.
The copy that the procedure makes can be altered by the procedure, but this does not alter the value of the original. When procedures work with copies of variables, they are known as value parameters.
Consider the following code example,
program Value_Parameters (output); procedure Nochange ( letter : char; number : integer ); begin writeln( letter ); writeln( number ); letter := 'A'; {this does not alter mainletter} number := 32; {this does not alter mainnumber} writeln( letter ); writeln( number ) end; var mainletter : char; {these variables known only from here on} mainnumber : integer; begin mainletter := 'B'; mainnumber := 12; writeln( mainletter ); writeln( mainnumber ); Nochange( mainletter, mainnumber ); writeln( mainletter ); writeln( mainnumber ) end.