Homework 16: Due Tuesday, November 20th

Read Chapter 11, sections 11.1 and 11.2, pages 632 through 644.

Complete the following problems:

Given:
   a[1] = 8
   a[2] = -4
   a[3] = 16
   a[4] = -12
   a[5] = 2
   a[6] = 11

   i = 2
   j = 3

Give the value of each of the following:

1.  a[6] + 6

2.  a[3]

3.  2 * a[4]

4.  a[a[5]]

5.  a[3] - a[4]

6.  a[i] + a[j]

7.  a[i + j]

8.  a[i] * a[j]

9.  a[i * j]

10. 2 * a[i]

11. a[2 * i]

12. a[j + 1]

13. a[j * 3 - i * 4]

14. a[a[3] / a[1]]


15. Write the statements to declare the following:
      an array of 25 characters
      an array of 100 integers
      an array of 10 floats


16. Given the declarations:
       int sample[8], i, k;
    Show the contents of the array sample after the following code
    is executed. Use a question mark to indicate any garbage values
    in the array.

    for (k = 0 ; k < 8 ; k++)
       sample[k] = 10 - k;


17. Using the same declarations given in problem 16, show the contents
    of the array sample after the following code is executed.

    for (i = 0 ; i < 8 ; i++)
       if (i <= 3)
          sample[i] = 1;
       else
          sample[i] = -1;


18. Given the declaration:
       int NUMS[100];
    write the statements to read values from the keyboard into NUMS.


19. Using the same declaration given in problem 18, write the statements
    to count the number of elements of NUMS which contain the value 0.

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