what is recursion explain with example

 Explain recursion with example

When a called function in turn calls another function a process of chaining occurs.
Recursion is a special case of this process where a function calls itself.

  For example :

  void main( )
  {
     Printf(“this is an example of recursion\n”);
      main( );
  }


Recursive functions can be effectively used to solve problems where solution is expressed in terms of suucessive applying the same solution to subsets of the problem.
 When we write recursive functions, we must have an if statement to force the function to return without the recursive call being executed. Otherwise, the function will never return.

Labels: