Quiz 5
Version 1

 

 

1. Does a for loop stop when its test is true, or when its test is false?

2. What role does the "index variable" of a for loop play?

3. What character separates the three parts of the control information in a for loop?

4. If a variable x is declared in the header of a loop, what parts of the program the loop is in can refer to x?

5. The index variable of a loop can be increased using a statement like index = index + 1. What's a more compact way to write this?

6. What does a break statement do?

7. What construction should you use to enumerate (e.g. print) all the values in a 2D table, a 2D maze, or the like?

8. In what journal did Edsger Dijkstra publish his infamous paper about goto statements?

10. What does the following loop print?

for  (int i = 1; i < 11; i++) {

   HMCSupport.out.println(i + " ");

} 

11. What does the following loop print?

for  (int i = 1; i <= 128; i = i * 2) {

   HMCSupport.out.println(i + " ");

} 

Last modified August 28 for Fall 99 cs5 by fleck@cs.hmc.edu


This page copyright ©1998 by Joshua S. Hodas. It was built with Frontier on a Macintosh . Last rebuilt on Tue, Sep 8, 1998 at 11:54:00 PM.
http://www.cs.hmc.edu/~hodas/courses/cs5/week_05/quiz.html