CS 1401, Quiz #6

Date: Monday, October 8, 2007
Name: ____________________________________________________________
Class section (9:30 am or 11:30 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:

for loops

linked lists

object oriented design

Graphical User Interface

2. Write a code that uses a for-loop to compute the factorial n! of a given number n, i.e., to multiply all the integers from 1 to 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?