0

What is recursion

plese give an example program

12th Jan 2017, 12:47 AM
amazing videos
amazing videos - avatar
2 Respostas
+ 3
fact(int n) { if (n==1) return 1; return fact(n-1)*n; } ... cout<<fact(n)//n! ...
12th Jan 2017, 12:53 AM
kerpoo
kerpoo - avatar
+ 2
As you can see in kerpoo's comment, recursion is when inside the function it calls itself (in simple words), you always need to have a condition (an exit condition)to end the recursion or it would continue "forever".
12th Jan 2017, 2:10 AM
C.E.
C.E. - avatar