- You are calling the function
fooona. - That is the order since you are printing AFTER you are processing the rest of the number. Try moving the call to
printfbefore the call tofooinfooand see if you get anything different. sumis changing because you are doingsum = sum + kand passing it to all the future calls.- When
neventually becomes0due to repeated divisions, the last call tofoostarts returning and following them all the previous calls start returning after printing the digit they had extracted usingn % 10
4
solved How does this foo function works?