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();
}
#include < iostream>
using namespace std;
class Myclass
{
public:
int func(int i)
{
if(i==0)
return 0;
cout<< i<< endl;
func(i-1);
}
};
int main()
{
Myclass obj;
obj.func(5);
return 0;
}
5
4
3
2
1