Name: ____________________________________________________ Alpha: _____________________

    Describe help received: _________________________________________________________________

  1. [10pts] Identify all function prototypes, function definitions, function calls, function arguments, and function parameters in the program below.
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    bool readRow(int len);
    
    int main()
    {
      int rows, cols;
      char t;
      cin >> rows >> t >> cols;
    
      int count = 0;
      for(int r = 0; r < rows; r++)
        if (readRow(cols))
          count++;
    
      cout << count << endl;
      return 0;
    }
    
    bool readRow(int len)
    {
      int n = 0;
      for(int i = 0; i < len; i++)
      {
        char c;
        cin >> c;
        if (c == 'Y')
          n++;
      }
      return n > 0;
    }
  2. [80pts] Write a program that reads in a list of fractions from the user, each separated by commas and the whole terminated by a semicolon, prints out the ones that are not in lowest terms. For example, a typical run might look like this:
    ~/$ ./hw
    2/4, 6/9, 3/11, 21/5, 8/10;
    2/4 is not in lowest terms!
    6/9 is not in lowest terms!
    8/10 is not in lowest terms!
    In writing this program, define and use a function int gcd(int,int); that takes two positive integers and returns their greatest common divisor. (Check out Class 10 to remind yourself about computing gcd's.) Turn In this cover sheet, along with a printout of your program along with a screen capture showing your program running on the above input (and, of course, this sheet).
  3. [10pts] Assume that you have a function with prototype void rep(int k, char c); that simply prints k copies of the character c to standard output (i.e. with cout). Write a code fragment using this function to print a hollow rectangle of *'s to the screen (as in an earlier homework) of dimension height 40 and width 65 characters, indented by 15 spaces.