What is recursion in C by R4R Team

Recursion:

-Function call itself again and again is known as the recursion.
-We can create a loop type structure with the help of the recursion.
-recursion require a stack memory for execution.

Infinite loop by recursion:


program-

#include< stdio.h>
int main()
{
main();
}

-Here when execution starts then it will go in main() function then we will again call main() function and this process continue run.

program-

#include < stdio.h>
int func(int x)
{
if(x==0)
return 0;
x=x-1;
printf("Call function\n");
func(x);
}
int main()
{
func(5);
}


output-

Call function
Call function
Call function
Call function
Call function




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!