completed assignment

Wrote functions and filled in comments for programming assignment #2.
Code was tested using matrix(1:4) and performed as expected.