Name: ____________________________________________________ Alpha: _____________Section: ________

Describe help received: _________________________________________________________________

See the bottom for how to submit your work.

Due: Before 0800 on next class day

  1. (10 pts) Read the lecture notes from today. Honestly declare how you read the notes.
    1. (10 pts) I read the notes carefully. I have a good understanding of the topics therein.
    2. (10 pts) I read the notes carefully, but I don't really understand the following points well:
      
      
      
      
    3. (0 pts) I didn't read the notes carefully.
  2. [10pts] The following program is supposed to read in numbers from the user (until a non-integer value) and report the number of negative, zero and positive values entered (counting duplicates).
    
      int zero = 0, pos = 0, neg = 0, k;
      while(cin >> k) 
      {
        if (k == 0)
          zero++;
        if (k > 0)
          pos++;
        else
          neg++;
      }
      cout << " neg = " << neg << endl;
      cout << "zero = " << zero << endl;
      cout << " pos = " << pos << endl;
    
    Unfortunately, this program has a bug. For example, with input
     2 0 -3 ; 
    it outputs
     neg = 2
    zero = 1
     pos = 1
    
    ... even though there is clearly one negative, one positive and one zero value.

    Annotate the code to show how to fix the bugs.

Bring to class