in reply to Difference between subroutine and functions

Wikipedia is a good friend.
Some programming languages, like Pascal and FORTRAN, distinguish between functions, which return values, and subroutines or procedures, which do not. Other languages, like C and LISP, do not make this distinction, and treat those terms as synonymous. The name method is commonly used in connection with object-oriented programming, specifically for subroutines that are part of objects.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Difference between subroutine and functions
by Anonymous Monk on Mar 15, 2010 at 05:39 UTC

    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.