                          Computer Science 101
                               Quiz 8      Name ______________________

1. In computing a recurrence in which the new value is the sum of the
   two previous value the correct order for the update is:
   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. new = old + older;               b. older = old;
      old = new;                          new = old + older;
      older = old;                        old = new;

   c. new = old + older;               d. These are all equivalent so
      older = old;                        any of them will work fine.
      old = new;

2. Which ONE of the the following is syntactically correct

   a. int sum(                 b. int sum{
      int a;                      int a,
      int b;                      int b,
      { return (a+b);}            { return (a+b);}

   c. int sum(                 d. int sum(
      int a,                      int a,
      int b,                      int b)
      { return (a+b);}            { return (a+b);}


3. If I have correctly written the sum function and try to call it using:

       total = sum(3, 4);

   a. I'll get an error because    b. I'll get an error because I
      I must pass it variables        must pass it variables not constants.
      named a and b

   c. It'll work and total will be  d. It won't work because the correct form
      set to 7.                        is sum(3, 4) = total;

4. Which of the following is NOT and advantage of breaking a large
   program up into a collection of functions:

   a. it facilitates top down       b. it reduces program execution (CPU)
      design                           time

   c. it controls nesting of if's   d. it improves program readability
      and while's

5. The proper way to run a program so that the standard input comes from
   a file named in.txt and the standard output goes to out.txt is:

   a. ./a.out in.txt out.txt        b. ./a.out < in.txt | out.txt

   c. ./a.out < in.txt out.txt      d. ./a.out < in.txt > out.txt

