Because it is inside an IF-statement?
and i thought void function is a function that does not return anything?
Your example has the part outside the if-statement. so It will execute.
On the other hand, my example an if-statement, and inside it it has a function caller (of the same function).
So i thought do4 and do5 is never reached..
Wrong, as in my code is wrong?
Back to my code, so do4 and do5 are executed when the function returns right?
When does that happen? (according to my code)
For example, when the condition in if-statement doesn't hold.
in other word, when does the function return?
(code consists of if-statement inside for loop, and a funtion caller of the same function inside it)
Then what is the difference between the original one and this one?
I moved do4 and do5 out of the if-statement?
If you move do4 and do5 outside the body of the if statement, then their execution no longer depends on the expression that controls whether the if statement is entered or not. do4 and do5 will be executed for every iteration of the loop regardless of what condition evaluates to.
So, regardless of the function being called, do4 and do5 are executed after the for loop of ends?
No. The function ends/returns after the for loop is executed. Why you want to conflate that with the execution of do4 and do5 is a mystery to me. do4 and do5 are executed for each iteration of the loop in which condition evaluates to true, prior to the for loop ending. I refer you again to the control structure tutorial linked before.
but if the function was called, the fucntion re-starts from line 1 right?
The function does not "re-start". A new invocation of the function begins with new local variables and a new argument that do not affect the ones belonging to any invocations that are still in progress. This can be seen, again, by studying the output of the example given previously in the duplicate thread.