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