Calling Procedure of Function

3 minutes read


There are three procedures to call a function.
1. Normal Calling Procedure: If a function calls any other function or any function is called by another function, it is referred as normal calling procedure of function.
For Example: If the body of function func1() contains calling statement of func2() so that control first of all will execute func1() and when it will find calling statement of func2() it will jump to the body of func2() to execute its body. After complete execution of called function control will return to the calling function.




2. Nested Call of function: Suppose function a() calls function b() and further function b() calls function c(), this type of function calling construct is called nested call of function. It can be also seen as extension of Normal Calling Procedure. Control first of all starts the execution of function a() and when it finds the calling statement of function b() it jumps into body of function b() to execute it. During execution of function b() it finds calling statement of function c() and then control jumps into body of function c() to execute it by interrupting the execution of function b(). After execution of function c() control returns to function b() (its calling function) and then rest of statements of b() are get executed. Then control returns from function b() to function a(). We should know the function which calls any other function is called as “calling function” and
the function which is called by any calling function is called as “called function”. In case of above example a() is calling for function b() and b() is calling function of function c() where b() and c() are called functions of a() and b() respectively. This type of function calling procedure is called as nested call of function.



3. Recursive call of function: If a function calls itself or a function called by itself, the construct is called as recursive call of function and this process of calling functions in such a way is called as “recursion”. For example body function a() contains any calling statement of a() then control start execution from calling a() function and when it finds calling statement of function a() it jumps to call itself. This works like cyclic process so there must be such condition, which enforce this iterative process. If condition given for termination of function call does not get satisfied, call becomes infinite. It means when calling and called both functions are identical, construct is called as recursion.



Internally these all subroutine calls are handled using definite set of instructions into computers. These are subroutine interrupts which are used to suspend the execution of subroutine. We will discuss this in further session.




Related Posts...