CS12 Homework 4

DUE: Sunday, 4/24, 11 pm (no late turn-in)


Collaboration policy: Collaboration is strongly ENCOURAGED, although of course, you should still submit your own solutions. Questions on exams and quizzes are frequently taken directly from homeworks.

Turn-in: Compose your homework on a simple text editor such as emacs or Notebook or Wordpad, and save it as a text file ("text-only format") with the extension .txt
Submit your work electronically to the hw4 folder on the cs secure server.
Remember to include the header template.


Do the following review exercises from Chapter 9 of the text (p. 364):

  1. R9.2

  2. R9.5

  3. R9.6

  4. R9.7

  5. R9.13

  6. R9.15

  7. R9.16

  8. R9.17

  9. Write a program that sets up a 10 x 12 two-dimensional array of integers - i.e. a matrix of 10 rows, 12 columns.
    a) Populate every element of the matrix with a random number between 1 and 1000;
    b) Print out the array as 10 rows x 12 columns (remember the setw() manipulator, which requires the <iomanip> library to be included).

  10. Re-write exercise 9 using two functions, populate and print, whose parameters are the matrix, and the number of rows.



You can find solutions to all odd-numbered review exercises here

You are encouraged to check these solutions after you have attempted your own answers.
I will deduct points for any responses that are directly copied fromn the text web site.
Remember that these exercises are designed to reinforce your understanding of the topics, and may very well turn up as quiz or exam questions.