2
0 Comments

Recursion in C Programming

In this tutorial, we will study what is recursion in c programming, the structure of the recursion function, the advantages and disadvantages of recursion in c, the types of recursion, and the factorial of a number using recursion.

Recursion in C Programming

Recursion is a process in which the function calls itself. Recursion is used to solve a problem by dividing it into small parts. Such functions which call themselves are called recursive functions.

Advantages and Disadvantages of Recursion in c

Advantages

  • If we solve a problem through Recursion, then there is no need to call the function again and again. If we call the function 1 time, it keeps calling itself till the end result comes.
  • The same problem is easily solved in recursion.

Disadvantages

  • Recursive programs are slower than normal programs.
  • Requires consuming extra memory.

Types of Recursion in C

Direct Recursion

Direct recursion is a recursion in which a function calls itself.

Indirect Recursion

In this, one function calls another function which in return calls it itself.

Originally posted on alimammiya.hashnode.dev

Credit on - Use My Notes

on March 3, 2021