in reply to Re: Difference between subroutine and functions
in thread Difference between subroutine and functions

function and subroutine are subprograms used in fortran.

function subprograms are used to compute a single value,while subroutine subprogram are used to compute several values or to perform task.

main difference between a subroutine and a function as follows:

1. No value is associated with the name of a subroutine,while the name of a function subprogram must have a value, numerical or logical.
2. A subroutine may be invoked only by a special calling statement-the call statement. The name of a function subprogram may be used in the same way as library functions,,i.e.,in arithmetic statements,etc.
3. A FUNCTION subprogram must have at least one argument, while a subroutine need not have any.
4. Since a function subprogram computes atleast one value, it must contain a return statement. A SUBROUTINE subprogram need not contain return statement.
  • Comment on Re^2: Difference between subroutine and functions