May be because when u look at the code.. rect(8) only returns and 8 is
stored into register but when it returns to rect(4) .it simply ends and
goes to rect(2) which in turn goes to rect(1).
So returned value is taken from that register that is filled with value
returned from it i.e 8.
May be
One execution path has no return. Most compilers will issue a warning
on that.
If a function doesn't return a value, that is undefined behavior.
It's unclear if the intent is to return rec(d) or i.
Better style is to have exactly one return at the end of the function.
Don
On Sep 25, 11:57 am,
not sure what interviewer meant here, does not look like compiler dependent
code,
and BTW, last recurrence yield 5 :) and not 8,
one possible def is, you have a function with no return and compiler
is independent for choosing what to return in this case, just a guess. Not
sure about cpp