Ch5 study guide - 1. A loop is a control structure that...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1. A loop is a control structure that causes certain statements to be executed over and over until certain conditions are met. True 2. The statement in the body of a while loop is the decision-maker. False 3. The loop condition is reevaluated after every iteration of the loop. True 4. If the initial condition of any while loop is false it will still execute once. False 5. An infinite loop executes indefinitely. True 6. In the case of an infinite while loop, initially the while expression (that is, the decision maker) is true. True 7. If the while expression becomes false in the middle of the while loop body, the loop terminates immediately . False 8. When a while loop terminates the control first goes back to the statement just before the while statement and then the control goes to the statement immediately following the while loop. False 9. The output of the Java code (Assume all variables are properly declared.) num = 100; while (num <= 148) num = num + 5; System.out.println(num); is: 150 True 10. The output of the Java code (Assume all variables are properly declared.) num = 450; while (num > 500) num = num + 5; System.out.println(num); is: 500 False 11. The while loop int j = 0; while (j < 20) j++; terminates when j > 20. False 12. Control variables are automatically initialized in a loop. False 13. A counter-controlled loop is used when the exact number of data entries is known. True 14. The output of the Java code (Assume all variables are properly declared.) n = 1; while (n < 5) { n++; System.out.print(n + " "); } System.out.println(); is: 2 3 4 5 True 15. The output of the Java code (Assume all variables are properly declared.) n = 1; while (n < 5) { System.out.print(n + " "); n++;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
} System.out.println(); is: 1 2 3 4 False 16. The output of the Java code (Assume all variables are properly declared.) n = 0; while (n < 5) { System.out.print(n + " "); n++; } System.out.println(); is: 0 1 2 3 4 5 True 17. In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered. True
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Ch5 study guide - 1. A loop is a control structure that...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online