Quiz 6
Version 1

 

 

:-)

1. What's the difference between a while loop and a do loop?

2. What is a "sentinel variable"?

3. What is the "pre-condition" of a loop?

4. What computation is done inside the loop of Euclid's method?

5. What is one "iteration" of a loop?

6. A standard joke is that a computer scientist once died in the shower because he was following the directions on a shampoo bottle: "lather, rinse, repeat."

What's wrong with the design of this loop?

7. Suppose that the test in your while loop checks the value of the variable qwerty. What does it mean if the Java compiler complains that qwerty may not have been initialized?

8. Here is a variation of the loop used in the notes to correct bad inputs. What does this mutant loop do?

  while (grade < 0 && grade >100) {  // Loop if bad grade
    HMCSupport.out.print("Grades must be between 0 and 100, re-enter: ");
    grade = HMCSupport.in.nextInt(); 
  }

9. What is the "post-condition" of a loop?

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 Sun, Oct 4, 1998 at 10:59:57 AM.
http://www.cs.hmc.edu/~hodas/courses/cs5/week_06/quiz.html