Question: 6. What does the following while loop print? int k = 1; while (k 50 ) && ( k < 80 ) ) continue; System.out.print(k
6. What does the following while loop print? int k = 1; while (k <= 100) { k+=10; if ( (k > 50 ) && ( k < 80 ) ) continue; System.out.print(k + ", "); } System.out.println(); 7. Hand trace the following code by making a table of values for a and b with rows corresponding to whenever lines 1, 2, 4, or 5 would be executed. Use the value of the variable after the line has executed. Give the expected output of the code fragment. 1 int a = 1; 2 int b = 10; 3 while (a < b) { 4 a += 2; 5 b -= 1; 6 } 7 System.out.println("a=" + a + ", b=" + b); 8. Hand trace the following code by making a table of values for a and b with rows corresponding to whenever lines 1, 2, 4, or 5 would be executed. Use the value of the variable after the line has executed. 1 int a = 5; 2 int b = 3; 3 while (a < 20) { 4 a = a + b; 5 b = a - b; 6 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
