You are here: Home / Topics / When Does the Recursion Occur in C?

When Does the Recursion Occur in C?

Filed under: C Programming on 2022-07-04 11:23:59

The recursion process in C refers to the process in which the program repeats a certain section of code in a similar way. In C Programming if a function calls itself from inside the same function is called recursion. The function which calls itself is called a recursive function and the function call is termed a recursive call.

While using recursion make sure that it has a base (exit) condition, otherwise the program will go in the infinite loop.

Example:

void recurse()

{

… .. …

recurse(); /* calling of the function by itself */

… .. …

}

int main()

{

… .. …

recurse();

… .. …

}

 

About Author:
B
Babita     View Profile
Learning is the best habbit. Learn new questions with me.