Homework 20: Due Tuesday, December 12th

Complete the following problems:

1.  Write a function count which will calculate and pass back the
    number of zeros found in a 2-dim array containing integers. The
    parameters are the array, the number of rows, and the number of
    columns. Assume that a global constant COLUMNS gives the number
    of columns in the array.


2.  Write a prototype for your count function.


3.  Write the statements to call count for a 2D array named table,
    and then print the number of zeros that were found. Assume that
    there are 50 rows and 40 columns in table.


4.  Modify your count function so that it has an additional parm, which
    is the number to count. For example, if the parm has the value 10,
    the count function will count and return the number of times that
    10 is found in the array.


5.  Write a prototype for the new version of the count function.


6.  Write a function change that will change each out-of-range integer
    element of a 2-dim array named table to -1. The parameters are the
    array, the number of rows, the number of columns, the smallest
    number in the range, and the largest number in the range. For
    example, if the valid range is 0 to 100, then all values outside
    this range will be replaced with -1. Assume that a global constant
    COLUMNS gives the number of columns in the array.


7.  Write a prototype for your change function.


8.  Write the statements to:
       declare an array with 100 rows and 200 columns
       read values into the array from a file named temp.dat
       call the change function with a range of 2 to 128
       call the second version of the count function to count the
    number of times the value -1 is found in the array
       print the result of the count function


Remember to type your answers and to make two copies of each homework assignment. One copy is submitted to me and the other you keep to use in the group discussions.


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2004