I am reviewing material for finals when i cam across this question to find out what prints from the following function
when print(4)
Code:
void print(int i)
{
if(i>=1)
{
printf("%d",i);
print(i-1);
printf("%d",i);
}
}
I understand that it enters with 4, the function is called within itself for i-1 so it reenters with 3, prints 3, than does it until i is 1 enters for the last time which then i which is 1 and 1-1 = 0, so it cannot enter the function no more however when i put compile the function i get the following
43211234, can anyone explain this output
i understand the 4321, thereafter is where i am lost
thanks in advance