break void function when the condition is met

Alaxwora:
but it does not exit void function.

Your incorrect use of language is making this very confusing.

When you say void loop in Reply #2 that should be the function loop(). The word void just tells the compiler that the function does not return any value.

The confusion then comes from your use of the term void function because the names of the other functions in your program are loop1() and loop2(). You don't (thank goodness) have any function named "function".

The net result is that I do not understand which of your functions is not behaving the way you want.

...R