Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. [20pts] Consider the following code snippet:
    void foo(int a, int& b);
    string bar(double k, string s);
    int i, j, k;
    double x, y, z;
    string u, v, w;
    
    For the functions calls below, circle only the ones that would be OK.
    a. foo(3,4)          b. foo(i,j)      c. foo(i,j+k)      d. foo('a',i)       e. foo("a",i)
    
    f. bar(3.0,4.0)      g. bar(x,u)      h. bar(x,u+v)      i. bar(a,v)         j. bar(x+y,"a")
    

  2. [80pts] Write a recursive function
    void rectangle(int rownum, int colnum, ostream& OUT);
    
    that prints out rectangles of *'s with rownum rows and colnum columns. In the spirit of bottom-up design, I'll provide you with a function you may want to use:
    void rep(char c, int k, ostream& OUT) {
      for( int i = 0; i < k; i++ )
        OUT << c;
    }
    
    Ever seen it before? Anyway, test your function with a program that reads the dimensions of the rectangle and the destination your writing to from the user, something like this:
    How many rows? 3
    How many columns? 2
    (S)creen of (F)ile? S
    
    **
    **
    **
    
    Turn In a printout of your program and a screen capture showing it run on the above example.