                          Computer Science 101
                               Quiz 7      Name ______________________

Supposed you are assigned the mission of computing the average of
a collection of integers to be read from the standard input.


1. The program must compute a count of the number of values in
   the file AND the sum of all the values in the file.  These
   computations

   a. must be done in separate      b. must be done in a single
      while loops                      while loops

   c. can be done equally easily    d. do not require any looping
      either way                       at all.

2. If the actual average is computed using the statement
    avg = sum / count;
   This statement must appear

   a. Before the while() loop(s)     b. After the while() loop(s)

   c. Within the while() loop(s)     d. The program can work correctly
                                        with it in any of the three
                                        locations.

3. Now suppose your mission is to read in a collection of pairs of
   integers and print out all pairs whose sum is 12. The print statement
   that is used to print the pairs must go:

   a. Before the while() loop        b. After the while() loop

   c. Within the while() loop        d. The program can work correctly
                                        with it in any of the three
                                        locations.

4. In the subsequence identification problem we discussed in class, value
   held the current value, old held the previously read value and older
   held the one before that.  The correct order for these statements to
   properly update the three variables is:

   a. hm = fscanf(stdin, "%d", &value);  b. old = value;
      old = value;                          hm = fscanf(stdin, "%d", &value);
      older = old;                          older = old;

   c. older = old;                       d. These are all equivalent so
      old = value;                          any of them will work fine.
      hw = fscanf(stdin, "%d", &value);


5. Which of the following tests can be used to print the value of
   val if and only if the decimal representation of val has more
   than a single digit. (Circle all that apply)

   a. if ((val < -9) && (val > 9))      b. if (!((val >= -9) && (val <= 9)))
         fprintf(...)                        fprintf(...)

   c. if ((val < -9) || (val > 9))      d. if (!((val >= -9) || (val <= 9)))
         fprintf(...)                        fprintf(...)
