Two-D_Arrays - CSCI152SampleQuizTwoDArrays

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCI 152                       Sample Quiz – Two-D Arrays   1.  Given these declarations: int A[3][4] = { { 8, 3, 0, 6 } , {11, 5, 1, 9} , { 10, 2, 4, 7 } }; int r, c; int val;                                                                                 a)  Draw a picture to show           where the assigned values           are located in the array.      b)  A has (how many)   ____  rows and  ____  columns.      c)  A has (how many total)  _____    elements.      d)  The value of A[2][1] is   ____  .      e)  Code a loop to print all the values in the second column  of A (spacing not important).      f)  Code loops to add 1 to all the elements in the first row, add 2 to all the elements in the            second row, and add 3 to all the elements in the third row.  2.  Given these declarations:    char B[4][4]; int x, y;                 Draw a picture to show the values assigned  by this code:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
     for (y = 0; y < 4; y++)             for (x = 0; x < 4; x++)                  if (x > y)                       B[x][y] = ‘#’;                  else if (x < y)                       B[x][y] = ‘$’;                  else B[x][y] = ‘*’;      a)  Write the prototype  for a void function which has a parameter of the entire array C.             b)   Show how you would call  the function to pass to it the array C.                                                                                                          4.  Given these declarations:    const int EMPLOYEES = 25;   const int DAYS = 7;  // Sun, Mon, Tue, Wed, Thu, Fri, Sat  int numEmployees;   // actual number of employees float hoursWorked [EMPLOYEES][DAYS];      a)  Calculate and print the number of employees who worked on Friday.                 b)  Calculate and print the number of hours that the last employee worked during the             week.
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5.  Given this array:    int A[5][3];   int row, col;      a.  Write the  prototype  for a function ArraySum which will calculate and return the sum of            all the values in A.      b.  Show how you would 
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/24/2011 for the course CSCI 1302 taught by Professor Harter during the Spring '11 term at Texas A&M University–Commerce.

Page1 / 10

Two-D_Arrays - CSCI152SampleQuizTwoDArrays

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online