int count = 1, i = 0; do { count *= ++i; if (count > 5) break; } while (i <= 4);
iteration 0: i = 0 + 1 = 1; count = 1 * 1 = 1; iteration 1: i = 1 + 1 = 2; count = 1 * 2 = 2; iteration 2: i = 2 + 1 = 3; count = 2 * 3 = 6; (6 > 5) breaks the loop
Login in to like
Login in to comment
or Read more about Java Quizzes
Login in to like
Login in to comment