Logic Series -5



Hi, in last session we have seen some concepts regarding the Iterators (loops) and conditional Statements, in today’s session we will one of the important aspect of any programming Language. It says it was one of the early members of programming languages and i.e. functions. So we will start with “What exactly the function is?” 

Function – A Set (piece) Of Code.

What is Function?

Function is a set of the code which is separates from the main method or you can say an execution method of programming language.

What is the Use of function?

Functions helps in one of the important factor of any programming language and that is Re usability, whichever the programming language is and whichever the structure they follows that can be a procedure oriented or Object oriented function plays an important role in that. As we can put a code which we going to use more than one time so we don’t have to write the similar code again and again we just have to call that function and it will do the rest of the work.

Is there any type of the function?

Yes, generally function can be of two types, 

System generated functions – these functions are predefined with in the library files of the programming languages. Generally input output functions or attribute function can be included in this type.

User Defined Function (Custom Functions) – These are the custom functions that are created by the users. This can contains any code that can reusable so that a user can access those functions in spite of that code.

A customised function can be divided into two types 

Calling function – through this function you can call the function which contains the min body of the code 

Called function – this function is the actual function which contains the body of the code.

In some programming language you have to define the prototype of that function too at the starting of the function, so your compiler can get to know that you are using certain functions and it must have the calling and called part.


If you are using a function called Addition .then it will be looks something like this.

Int Addition () /* through this our compiler can get to know that we will using a certain function called Addition*/

main () {

Addition (); /* this is the calling function through this generally we can call the function or we can say initialise the function */


Addition () {

/* Body of the function */


Now how we will send the data from one function to another function.

Their actually have two ways to do this.

1) Make the Variable Scope Global so that each and every function has common value for those Variables.

2) Send the parameters with the functions, So the local values of the parent function can be access by the called function.

Recursive Function:

For That first we need to understand what recursion stand for?

Recursion is the process of Repeated Actions, The process which repeats itself is identifying as the recursive Action.

So what is Recursive Function then?

One can say a function which repeats its action might say an Recursive function, So yes A function which repeats itself by calling itself is known as a Recursive function.


a() /* first call to the function */

function a() /* body of the function */


a();  /* this function will calls itself for repeated action*/



-- EduWithUs Team