CS 1401, Quiz #6

Date: Tuesday, February 26, 2008
Name: ____________________________________________________________
Class section TR 9:00 am

1. For each of the following topics, write "yes" or "no" depending on whether this topic is covered in Chapter 6, the chapter that you were supposed to read before the class:

object-oriented design

ternary operators


Graphical User Interface

2. Write a code that uses a for-loop to add the squares of all the integers from 7 to a given number n. Do not worry about reading this number or printing the results; assume that the number is there.

3. Write a similar code, but using the while loop.


4. For extra credit: Explain the difference between while- and for-loops. When is it better to use while loops and when for loops? Based on your explanation, what is better for computing the factorial of n?