Posted in All Posts, Semester 2

Recursive Functions in C

Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.

The C programming language supports recursion, i.e., a function to call itself.
A function which calls itself is called a recursive function. But while using recursion, programmers need to be careful to define an exit condition from the function, otherwise it will go into an infinite loop.

Below is a recursive function that generates an infinite loop.

The program below is an example of recursive function which stops after a few iterations.

Recursive functions are very useful to solve many mathematical problems, such as calculating the factorial of a number, generating Fibonacci series, sum of a series etc.

We’ll see use of recursive functions in various programs in upcoming posts.

We hope that you found this article to be helpful.
Please share your thoughts in the Comments Section.

If you liked this article, then please like our Facebook page.

Suggested Reading

4 thoughts on “Recursive Functions in C

Comment your thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.