CS1411 - 160 - Programming Principles I, Spring 2005

Lab assignment 6


This weeks you will practice multi-dimensional arrays

Mandatory work

Your TA will check that you have done the following things (you may leave once their done) :

Print Array

Write a printArray function that takes an two-dimensional array of char and the size of both dimensions as parameter. Output this array as a matrix, and add character coordinates on top and bottom.



(In this case the array was filled with all x's, and the sizes given were 6 and 6)

Hint: To output A for 0, B for 1, C for 2, etc. you can use the property that characters are just numbers as follows: (assuming i is of type int)

cout << ('A'+i);

Note: Safe your work, you'll need it for the programming project!

Main function

To test your printArray function, give a main function with declares an array, fills it with some usefull values, and then calls the print function to print it

Optional work

Some other things that you might try:

  • Initialize the array with all spaces ' '.
  • Randomly set a * somewhere into your array.
  • Randomly set another * in the array, making sure it is not at the same position as the previous one.
  • Can you do that with 5 *'s ?


Please check the labs page on how to get started. There are instructions for visual studio (use version 6) and XCode

Please give the Macs a try. If you simply cannot work with them, go to PE 119, but let your TA know.

Sample programs

have moved to the examples page


For help: ask your TA! He is here to help you!

If the instructions are unclear or you have any other questions, please email me