Class 10 W 2/13 Comp 110 Loops while listing 4.1 do-while listing 4.2 loop control variable 4 parts of every loop infinite loop loop control variable - variable in condition that determines number of times loop executes 4 parts of every loop initialization of loop control variable (and any other variables in the body of the loop) loop test (= condition) - decide if loop is to be executed update of loop control variable In-class exercise For each of the following i) identify the 4 parts of the loop ii) show the output of the code segment a) int count = 0; // initialization while( count < 5 ) { // condition System.out.println(count); // body count++; // same as count = count + 1; update } count 0,1,2,3,4,5 Output 0 1 2 3 4 b) int count = 0; while( count < 5 ) { count++; System.out.print(count + " "); } count 0,1,2,3,4,5 Output 1 2 3 4 5 c) int count = 0; while( count < 5 ) { System.out.println(count); } d) int count = 0; do { System.out.println(count); count++; } while( count < 0 ); System.out.println( "count after loop = " + count); e) int count = 0; while( count < 0 ) { System.out.println(count); count++; } System.out.println( "count after loop = " + count);