Multi-D Arrays

  1. Declare a 2-D array with 5 columns and 2 rows (use constants).
  2. Draw out the following 2-D array:
    int vals[3][2] = { 1,2,3,4,5,6 };
  3. Write a function that returns the maximum value in a 2-D array.
  4. Write a function that takes a 2-D array with 10 rows, 2 columns and prints the sum of each row.
  5. Write a function that takes a 2-D array with 50 rows, 2 columns and swaps the positions of each row.
  6. T/F: When using an array element, C performs bound checks on the value of the index.
  7. T/F: If an array has been declared as consisting of 10 elements and you use an index of 12, C will notify you of the error when the program is compiled.
  8. T/F: When passing a 2-D array to a function, the called function receives a copy of the array; this is because C uses pass by value.
  9. T/F: The outer braces in the initialization statement of a two-dimensional array can be omitted.
  10. T/F: Nested loops are especially useful when dealing with two-dimensional arrays because they allow the programmer to easily cycle through each element.
  11. T/F: Arrays of three, four, five, six, or more dimensions can be viewed as mathematical n-tuples of order three, four, five, six, and so on, respectively.
  12. A(n) ____, is used to store and process a set of values, all of the same data type, that forms a logical group.
    a.	data structure	c.	array	
    b.	scalar variable	d.	atomic variable
  13. A ____ is a list of values of the same data type that is stored using a single group name.
    a.	one-dimensional array	c.	three-dimensional array	
    b.	two-dimensional array	d.	matrix
  14. Each item in an array is called a(n) ____ of the array.
    a.	subscript	c.	index	
    b.	variable	d.	element
  15. In a one-dimensional array in C, the first element has an index of ____.
    a.	NULL	c.	0	
    b.	-1	d.	1
  16. A two-dimensional array is sometimes referred to as a ____.
    a.	list	c.	queue	
    b.	vector	d.	table
  17. ____ declares an array of three rows and four columns.
    a.	int val[3,4];	c.	int val[3][4];	
    b.	int val[4,3];	d.	int val[4][3];
  18. The term ____ uniquely identifies the element in row 1, column 3.
    a.	val[3][1]	c.	val[3,1]	
    b.	val[1][3]	d.	val[1,3]
  19. The initialization of a two-dimensional array is done in ____ order.
    a.	ascending	c.	row	
    b.	descending	d.	column
  20. Write a function named getCol that takes 3 parameters:
    (1) 2-D int array with NUMROWS and NUMCOLS for the number of rows and columns
    (2) an int for the column number desired
    (3) 1-D int array with space for NUMROWS elements
    Function should modify the 1-D array to have the elements in the column specified from parameter #2.
  21. Write a function that takes a 2-D array of integers and returns the maximum value in the array (reference NROWS and NCOLS for # of rows and columns).
  22. T/F: When passing a 2-D array to a function, the function cannot change the original array from the calling function.
  23. Build a crossword puzzle program, or a word search program.