A functions is referenced by using its name in an expression, whereas a subroutine is referenced by a CALL statement. However, NAME can not have a type. . In a subroutine, values are returned via the arguments. Subroutines are more versatile than functions because they can modify arguments, use them without modification, or require no arguments at all. The subroutine on the left has no arguments and simply prints out a message when it is called.
Simple variables are the easiest to pass, but there are several implications to consider.
The expression will be evaluated before passing and the type must agree with the formal argument. Arrays are passed by using the array's name. There are a few notes to consider. The corresponding array argument in the subroutine must be dimensioned no larger than the actual array in the main program. Check to make sure n is less than or equal to 100.