Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• # Recursion in c

• 0
• 2
• 0
• 0
• 0
• 0
• 0
• 0
• 171
Comment on it

In C programming language when a function calls itself over and over again , that function is called recursive function .The process of function calling itself repeatedly is known as recursion .

Recursion is supported by C programming language i.e., a function to call itself repeatedly again and again and while using this function the programmer needs to be careful that there should be an exit function in the program,else it will go in infinite loop.

In the C recursive function it allow us to break a complex problem into identical sub-problems recursively until each and every sub problem are simple enough so that they can be solved directly in C language.Then at last the solutions of the identical sub problems are combined to make the final solution.

In recursion we use the divide and conquer approach to divide the original problem to sub problem and hence replaces complex nesting code.

C Recursion uses lot of stack space, usually it is not used when the program is small and running on a PC. It is hard to debug the code or extend the functionality in case of recursive logic.

Below is the code example of Factorial using recursion

```            #include <stdio.h>
#include <conio.h>
int facto (int);
int main()
{
int numb,p;
printf(\nEnter a positive number:);
scanf(%d,&numb);
return 0;
}
int facto(int m)
{
if(n==0)
return 1;
else
return(n*facto(m-1));
}
```

Output:

```Enter a positive number: 5
Factorialof 5 is:120
```

## 0 Comment(s)

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General