Preethi Raman
Preethi Raman
Branch Unspecified
01 Dec 2008

How to stop recursion function?

Can you plzz say me how to stop the recursion function
krishna_540

krishna_540

Branch Unspecified
02 Dec 2008
Preethi Raman
Can you plzz say me how to stop the recursion function
Generally the recursion function will quit based on the condition stated in the function or using a break statement or a return function
krishna_540

krishna_540

Branch Unspecified
02 Dec 2008
Preethi Raman
Can you plzz say me how to stop the recursion function
can u pls tell me the exact problem wher u want to break the function so that i can be more clear
Ashutosh_shukla

Ashutosh_shukla

Branch Unspecified
02 Dec 2008
Recursive functions always contain 2 parts.First that indicates action to be done by this call and second is the one that recursively calls the function again.We may specify condition that is to be satisfied for calling recursively or may also specify the condition of terminating the recursion process.
For eg: In factorial we continously call until the argument passed is 1 and when argument is 1 we simply return 1 so stop the recursion
Preethi Raman

Preethi Raman

Branch Unspecified
02 Dec 2008
Thanks a lot for your answer..and also does the recursion function forms
an infinite loop???
Its clear that we can terminate the recursive function either by a break,goto,and return functions..
komputergeek

komputergeek

Branch Unspecified
03 Dec 2008
break and goto are used to terminate loop.
komputergeek

komputergeek

Branch Unspecified
03 Dec 2008
Preethi Raman
does the recursion function forms
an infinite loop???
If you don't specify any statement to terminate,it will form infinite loop.

e.g
void func()
{
       func();
}
rscrbv

rscrbv

Branch Unspecified
18 Dec 2008
Preethi Raman
Can you plzz say me how to stop the recursion function
i think u r not knowing correct concept of recursion
Given here in pseudocode:​
function factorial(n)
{
if (n<=1)
return 1;
else
return n * factorial(n-1);
}​
moksh

moksh

Branch Unspecified
19 Dec 2008
recursion function have a base condition ....

every time the function is called ... the value moves closer to he base condition....
Ahmad Suudi

Ahmad Suudi

Branch Unspecified
20 Oct 2014
Please try :

publicstaticvoidMain(string[]args)
{
tampil(10);
}

privatestaticvoidtampil(inti)
{
Console.WriteLine("Halo"+i.ToString());

if(i>0)
tampil(i-1);
}

Share this content on your social channels -

Only logged in users can reply.