Explain User defined function and How to call the User defined function explain with example

Explain User defined function and How to call the User defined function

Need of  User defined function

It makes program easier to understand, debug and test.
 It saves both time and space.
 It facilitates top-down modular programming. In this
  programming style, the  high level logic of the overall problem is
  solved first while the details of each  lower-level functions are
   addressed later.
 The length of a source program can be reduced by using
   functions at  appropriate places.
 It is easy to locate and isolate a faulty function for further
  investigation.
 A function may be used by many other programs.

In order to make use of a user-defined function, we need

to establish three elements that are related to functions :

Function definition
Function call
Function declaration

The function definition is an independent program module that is
     specially written to implement the requirements of the function.
In order to use this function we need to invoke it at a required place in the program.  This  is  known  as  function  call.  The  program
    (or a function) that calls the function is referred to as the
     calling program or calling function.
The calling program should declare any function (like declaration of a variable) that is to be used later in the program. This is known as function declaration or function prototype.

Labels: