Categories of Functions:
Function can be broadly categorized into four ways depending
upon whether arguments are passed or not and whether a value is returned or
not.
- · Function with no arguments and no return value.
- · Function with arguments and no return values.
- · Functions with arguments and one return value.
- · Functions with no arguments and return a value.
- · Function that returns multiple values.
No Arguments and No
Return Values:
When a function has no arguments, it does not receive any
data from the calling function. Similarly, when it does not return a value, the
calling function does not receive any data from the called function. In effect,
there is no data transfer between the calling function and the called function.
This is depicted in Fig. The dotted lines indicate that there is only a
transfer of control but not data.
Arguments but No
Return Values:
A function which is invoked by passing some arguments from
the calling function but doesn’t return back any value to the calling function
is a function with parameters but no return value. There exists only one way of
communication of data from the calling function to the called function.
Functions with
arguments and one return value:
A function with arguments and return type, on invocation
passes arguments to the called function and return a value back to the calling
function. Thus a two way communication is made possible between the calling
function and the called function.
Post a Comment