The Function which Calles Itself is known as Recursive Function.
If I ask you to print numbers from 1 to 10 without using loop.
Can you do??? No... So, Let me introduce you to the concept of Recursion.
Once you call the Function recursion then the statements inside the function will run. i.e. recusion(); will be called again.
We have declared a Global Scope Variable no
Then Function called printNo();
Let's Understand the Function printNo();
At First, no is printed in Console.
no+=1 i.e. no = no + 1
Then we have used, If Condition
if no is less than 10 then function will be called again.
otherwise, function will be terminated.
You Should be Very Careful while using the Recursive Function. Because Many Beginners When Try to do Looping using Recursive Function, They usually Forget to Put Condition to Stop the Loop, resulting in Infinite Loop and Crashing of the Program.
So, Don't Forget to Put Condition to Stop the Loop, you can use if condition to stop the Iteration of The Loop.