FreePrograms


C language is a middle level language. It is a structured language. C language is a case sensitive language. All syntax written in c language is in lower case. C is the basis for C++.
  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming Data Structures in C C interview Questions

Recursion

Nesting of functions is when a function calls another function and that second function calls the third one . But a recursive function is the function that calls itself repeatedly.




Recursion is simply a function that calls itself, its advantage is that the code we write gets short and it gets easy to solve problems.

Example1:

Example2:

void rec()
{
rec(); //Function calls itself
}

int main()
{
rec(); //Setting off recursion
}

How to Calculate Factorial Using Recursion

Recursion vs Iteration

Recursion is repeatedly calling the function, whereas Iteration is nothing but just looping until condition doesn't satisfy.

Recursive is lot slower than iterative. Recursive function uses more memory.

Recursion is when a part of code calls itself (directly or indirectly) whereas iteration works in cycle as mentioned before.

A recursive function works through the process of calling itself until a condition is met. Iteration uses a looping control structure (while, do while, for) to repeat a section of code until a condition is met

 

COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM