As an illustration of the power of procedures, the following program was written and shows how the same procedure can do different operations depending on the parameters that are passed to it. It does this because Roman numerals follow the same scheme except the symbols change. Functions should be used if a single value is computed and is to be passed back to the calling program. Procedures modify global variables or have side effects. That is they change something about the program's environment Functions can be placed anywhere a variable can appear except in a read or readln statement.
Procedures appear on a single line by themselves.
Local variables should be used when a variable is used only inside a function or procedures and no value is passed in and out of the subprogram. If a parameter is to pass a value into a subprogram, it should be a pass by value parameter and will not have the var in front of it in the subprogram's definition. If a parameter is to pass a value out of a subprogram, it should be a pass by reference parameter and will have the var word in front of it in the subprogram's definition. The parameters at the call to the subprogram are referred to as actual parameters. The parameters at the definition are referred to as the formal parameters.