How can you prevent endless loop
Anonimo
Ensure you have at least one statement within the loop that changes the value of the comparison variable. (That is, the variable you use in the loop's comparison statement.) ... Never leave the terminating condition to be dependent on the user.