How do I find a maximum number of consecutive non-zero values in the array?

What happens if the longest sequence of non-zero values occurs right up to the end of the array? Does the appropriate variable get updated?